Handle snprintf() returning -1
MFC after: 2 weeks
This commit is contained in:
parent
5adb5c82e3
commit
7806546c39
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81962
@ -249,6 +249,7 @@ AliasHandleIrcOut(struct ip *pip, /* IP packet to examine */
|
||||
if ( dcc_link ) {
|
||||
struct in_addr alias_address; /* Address from aliasing */
|
||||
u_short alias_port; /* Port given by aliasing */
|
||||
int n;
|
||||
|
||||
#ifndef NO_FW_PUNCH
|
||||
/* Generate firewall hole as appropriate */
|
||||
@ -256,17 +257,26 @@ AliasHandleIrcOut(struct ip *pip, /* IP packet to examine */
|
||||
#endif
|
||||
|
||||
alias_address = GetAliasAddress(link);
|
||||
iCopy += snprintf(&newpacket[iCopy],
|
||||
n = snprintf(&newpacket[iCopy],
|
||||
sizeof(newpacket)-iCopy,
|
||||
"%lu ", (u_long)htonl(alias_address.s_addr));
|
||||
if( iCopy >= sizeof(newpacket) ) { /* Truncated/fit exactly - bad news */
|
||||
if( n < 0 ) {
|
||||
DBprintf(("DCC packet construct failure.\n"));
|
||||
goto lBAD_CTCP;
|
||||
}
|
||||
if( (iCopy += n) >= sizeof(newpacket) ) { /* Truncated/fit exactly - bad news */
|
||||
DBprintf(("DCC constructed packet overflow.\n"));
|
||||
goto lBAD_CTCP;
|
||||
}
|
||||
alias_port = GetAliasPort(dcc_link);
|
||||
iCopy += snprintf(&newpacket[iCopy],
|
||||
n = snprintf(&newpacket[iCopy],
|
||||
sizeof(newpacket)-iCopy,
|
||||
"%u", htons(alias_port) );
|
||||
if( n < 0 ) {
|
||||
DBprintf(("DCC packet construct failure.\n"));
|
||||
goto lBAD_CTCP;
|
||||
}
|
||||
iCopy += n;
|
||||
/* Done - truncated cases will be taken care of by lBAD_CTCP */
|
||||
DBprintf(("Aliased IP %lu and port %u\n", alias_address.s_addr, (unsigned)alias_port));
|
||||
}
|
||||
|
@ -249,6 +249,7 @@ AliasHandleIrcOut(struct ip *pip, /* IP packet to examine */
|
||||
if ( dcc_link ) {
|
||||
struct in_addr alias_address; /* Address from aliasing */
|
||||
u_short alias_port; /* Port given by aliasing */
|
||||
int n;
|
||||
|
||||
#ifndef NO_FW_PUNCH
|
||||
/* Generate firewall hole as appropriate */
|
||||
@ -256,17 +257,26 @@ AliasHandleIrcOut(struct ip *pip, /* IP packet to examine */
|
||||
#endif
|
||||
|
||||
alias_address = GetAliasAddress(link);
|
||||
iCopy += snprintf(&newpacket[iCopy],
|
||||
n = snprintf(&newpacket[iCopy],
|
||||
sizeof(newpacket)-iCopy,
|
||||
"%lu ", (u_long)htonl(alias_address.s_addr));
|
||||
if( iCopy >= sizeof(newpacket) ) { /* Truncated/fit exactly - bad news */
|
||||
if( n < 0 ) {
|
||||
DBprintf(("DCC packet construct failure.\n"));
|
||||
goto lBAD_CTCP;
|
||||
}
|
||||
if( (iCopy += n) >= sizeof(newpacket) ) { /* Truncated/fit exactly - bad news */
|
||||
DBprintf(("DCC constructed packet overflow.\n"));
|
||||
goto lBAD_CTCP;
|
||||
}
|
||||
alias_port = GetAliasPort(dcc_link);
|
||||
iCopy += snprintf(&newpacket[iCopy],
|
||||
n = snprintf(&newpacket[iCopy],
|
||||
sizeof(newpacket)-iCopy,
|
||||
"%u", htons(alias_port) );
|
||||
if( n < 0 ) {
|
||||
DBprintf(("DCC packet construct failure.\n"));
|
||||
goto lBAD_CTCP;
|
||||
}
|
||||
iCopy += n;
|
||||
/* Done - truncated cases will be taken care of by lBAD_CTCP */
|
||||
DBprintf(("Aliased IP %lu and port %u\n", alias_address.s_addr, (unsigned)alias_port));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user