aboutsummaryrefslogtreecommitdiffstats
path: root/packet-isakmp.c
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2003-05-24 17:45:10 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2003-05-24 17:45:10 +0000
commita67f5b2f3e9565bcd89029b41280c7570eac1b2c (patch)
tree29e407f5a20819fdc0040e2bb301f6240053c46f /packet-isakmp.c
parent144e70d33f65302c90461b828722234e68577840 (diff)
Fix instances where the return value of snprintf() was being checked for -1,
but not for <buf_size> or greater. Discovered by Timo Sirainen. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7731 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-isakmp.c')
-rw-r--r--packet-isakmp.c17
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;