diff options
author | Gerald Combs <gerald@wireshark.org> | 2003-05-24 17:45:10 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2003-05-24 17:45:10 +0000 |
commit | 356ddbd284075257edda1b7a8c77fe9539f817b5 (patch) | |
tree | 29e407f5a20819fdc0040e2bb301f6240053c46f /packet-isakmp.c | |
parent | 4d5243dcc74a17157213fef24d37e9fdbbb693bf (diff) | |
download | wireshark-356ddbd284075257edda1b7a8c77fe9539f817b5.tar.gz wireshark-356ddbd284075257edda1b7a8c77fe9539f817b5.tar.bz2 wireshark-356ddbd284075257edda1b7a8c77fe9539f817b5.zip |
Fix instances where the return value of snprintf() was being checked for -1,
but not for <buf_size> or greater. Discovered by Timo Sirainen.
svn path=/trunk/; revision=7731
Diffstat (limited to 'packet-isakmp.c')
-rw-r--r-- | packet-isakmp.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/packet-isakmp.c b/packet-isakmp.c index 3f421f4440..04f26b3b0e 100644 --- a/packet-isakmp.c +++ b/packet-isakmp.c @@ -4,7 +4,7 @@ * for ISAKMP (RFC 2407) * Brad Robel-Forrest <brad.robel-forrest@watchguard.com> * - * $Id: packet-isakmp.c,v 1.61 2003/04/28 20:03:37 guy Exp $ + * $Id: packet-isakmp.c,v 1.62 2003/05/24 17:45:10 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1126,8 +1126,9 @@ situation2str(guint32 type) { if (type & SIT_IDENTITY) { ret = snprintf(msg, SIT_MSG_NUM-n, "%sIDENTITY", sep); - if (ret == -1) { - /* Some versions of snprintf return -1 if they'd truncate the output. */ + if (ret == -1 || ret >= SIT_MSG_NUM-n) { + /* Truncated. */ + msg[SIT_MSG_NUM] = '\0'; return msg; } n += ret; @@ -1139,8 +1140,9 @@ situation2str(guint32 type) { return msg; } ret = snprintf(msg, SIT_MSG_NUM-n, "%sSECRECY", sep); - if (ret == -1) { - /* Some versions of snprintf return -1 if they'd truncate the output. */ + if (ret == -1 || ret >= SIT_MSG_NUM-n) { + /* Truncated. */ + msg[SIT_MSG_NUM] = '\0'; return msg; } n += ret; @@ -1152,8 +1154,9 @@ situation2str(guint32 type) { return msg; } ret = snprintf(msg, SIT_MSG_NUM-n, "%sINTEGRITY", sep); - if (ret == -1) { - /* Some versions of snprintf return -1 if they'd truncate the output. */ + if (ret == -1 || ret >= SIT_MSG_NUM-n) { + /* Truncated. */ + msg[SIT_MSG_NUM] = '\0'; return msg; } n += ret; |