Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ortmann committed Oct 5, 2023
1 parent 45445f2 commit 27def15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,17 +1354,6 @@ void sub_lang(int idx, char *text)
dprintf(idx, "%s\n", s);
}

/* This will return a pointer to the first character after the @ in the
* string given it. Possibly it's time to think about a regexp library
* for eggdrop...
*/
char *extracthostname(char *hostmask)
{
char *p = strrchr(hostmask, '@');

return p ? p + 1 : "";
}

/* Show motd to dcc chatter
*/
void show_motd(int idx)
Expand Down
12 changes: 11 additions & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,16 @@ int sanitycheck_dcc(char *nick, char *from, char *ipaddy, char *port)
return 1;
}

/* This will return a pointer to the first character after the last @ in the
* string given it.
*/
static char *extracthostname(char *hostmask)
{
char *p = strrchr(hostmask, '@');

return p ? p + 1 : "";
}

int hostsanitycheck_dcc(char *nick, char *from, sockname_t *ip, char *dnsname,
char *prt)
{
Expand All @@ -1601,12 +1611,12 @@ int hostsanitycheck_dcc(char *nick, char *from, sockname_t *ip, char *dnsname,
/* It is disabled HERE so we only have to check in *one* spot! */
if (!dcc_sanitycheck)
return 1;
strlcpy(badaddress, iptostr(&ip->addr.sa), sizeof badaddress);
strlcpy(hostn, extracthostname(from), sizeof hostn);
if (!strcasecmp(hostn, dnsname)) {
putlog(LOG_DEBUG, "*", "DNS information for submitted IP checks out.");
return 1;
}
strlcpy(badaddress, iptostr(&ip->addr.sa), sizeof badaddress);
if (!strcmp(badaddress, dnsname))
putlog(LOG_MISC, "*", "ALERT: (%s!%s) sent a DCC request with bogus IP "
"information of %s port %s. %s does not resolve to %s!", nick, from,
Expand Down
1 change: 0 additions & 1 deletion src/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ void rem_help_reference(char *);
void add_help_reference(char *);
void debug_help(int);
void reload_help_data(void);
char *extracthostname(char *);
void show_banner(int i);
void make_rand_str_from_chars(char *, int, char *);
void make_rand_str(char *, int);
Expand Down

0 comments on commit 27def15

Please sign in to comment.