summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2001-08-18 22:15:29 +0000
committerbrian <brian@cvs.openbsd.org>2001-08-18 22:15:29 +0000
commitfb5df037b381aa36ca6f7aadbe34627b708f1b18 (patch)
treee75554aa613e5476498d81247904fbc6d9766c69 /usr.sbin
parent1d67028f2292ff8ef592c61b42904037c5fbea5b (diff)
Deal with snprintf returns properly
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ppp/alias_irc.c22
-rw-r--r--usr.sbin/ppp/ppp/mp.c6
2 files changed, 21 insertions, 7 deletions
diff --git a/usr.sbin/ppp/ppp/alias_irc.c b/usr.sbin/ppp/ppp/alias_irc.c
index 80617a58ba1..afcf859fd45 100644
--- a/usr.sbin/ppp/ppp/alias_irc.c
+++ b/usr.sbin/ppp/ppp/alias_irc.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: alias_irc.c,v 1.5 2001/06/07 09:32:55 brian Exp $
+ * $OpenBSD: alias_irc.c,v 1.6 2001/08/18 22:15:28 brian Exp $
*/
/* Alias_irc.c intercepts packages contain IRC CTCP commands, and
@@ -249,6 +249,7 @@ lFOUND_CTCP:
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 @@ lFOUND_CTCP:
#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],
- sizeof(newpacket)-iCopy,
- "%u", htons(alias_port) );
+ 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));
}
diff --git a/usr.sbin/ppp/ppp/mp.c b/usr.sbin/ppp/ppp/mp.c
index dae878ab1f8..cce2bcba043 100644
--- a/usr.sbin/ppp/ppp/mp.c
+++ b/usr.sbin/ppp/ppp/mp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: mp.c,v 1.23 2001/07/31 15:20:19 brian Exp $
+ * $OpenBSD: mp.c,v 1.24 2001/08/18 22:15:28 brian Exp $
*/
#include <sys/param.h>
@@ -1117,6 +1117,10 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
l = snprintf(s->socket.sun_path, sizeof s->socket.sun_path, "%sppp-%s-%02x-",
_PATH_VARRUN, peer->authname, peer->enddisc.class);
+ if (l < 0) {
+ log_Printf(LogERROR, "mpserver: snprintf(): %s\n", strerror(errno));
+ return MPSERVER_FAILED;
+ }
for (f = 0; f < peer->enddisc.len && l < sizeof s->socket.sun_path - 2; f++) {
snprintf(s->socket.sun_path + l, sizeof s->socket.sun_path - l,