From 3d0ac5c69ad5a9d133f8d25100735c49b99153c7 Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Tue, 21 Feb 2012 13:59:08 +0000 Subject: Check if the string exists first. svn path=/trunk/; revision=41109 --- pcapio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pcapio.c b/pcapio.c index 9521fb8408..6f7d600acc 100644 --- a/pcapio.c +++ b/pcapio.c @@ -396,35 +396,35 @@ libpcap_write_interface_description_block(FILE *fp, block_total_length = sizeof(struct idb) + sizeof(guint32); /* OPT_COMMENT */ - if ((strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) { + if ((comment)&&(strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) { block_total_length += sizeof(struct option) + (guint16)(ADD_PADDING(strlen(comment) + 1)); have_options = TRUE; } /* IDB_DESCRIPTION */ - if ((strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) { + if ((descr)&&(strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) { block_total_length += sizeof(struct option) + (guint16)(ADD_PADDING(strlen(descr) + 1)); have_options = TRUE; } /* IDB_NAME */ - if ((strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) { + if ((name)&&(strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) { block_total_length += sizeof(struct option) + (guint16)(ADD_PADDING(strlen(name) + 1)); have_options = TRUE; } /* IDB_FILTER */ - if ((strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) { + if ((filter)&&(strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) { block_total_length += sizeof(struct option) + (guint16)(ADD_PADDING(strlen(filter) + 1)); have_options = TRUE; } /* IDB_OS */ - if ((strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) { + if ((os)&&(strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) { block_total_length += sizeof(struct option) + (guint16)(ADD_PADDING(strlen(os) + 1)); have_options = TRUE; @@ -452,7 +452,7 @@ libpcap_write_interface_description_block(FILE *fp, idb.snap_len = snap_len; WRITE_DATA(fp, &idb, sizeof(struct idb), *bytes_written, err); /* write comment string if applicable */ - if ((strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) { + if ((comment)&&(strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) { option.type = OPT_COMMENT; option.value_length = (guint16)(strlen(comment) + 1); WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err); @@ -462,7 +462,7 @@ libpcap_write_interface_description_block(FILE *fp, } } /* write interface name string if applicable */ - if ((strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) { + if ((name)&&(strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) { option.type = IDB_NAME; option.value_length = (guint16)(strlen(name) + 1); WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err); @@ -472,7 +472,7 @@ libpcap_write_interface_description_block(FILE *fp, } } /* write interface description string if applicable */ - if ((strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) { + if ((descr)&&(strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) { option.type = IDB_DESCRIPTION; option.value_length = (guint16)(strlen(descr) + 1); WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err); @@ -482,7 +482,7 @@ libpcap_write_interface_description_block(FILE *fp, } } /* write filter string if applicable */ - if ((strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) { + if ((filter)&&(strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) { option.type = IDB_FILTER; option.value_length = (guint16)(strlen(filter) + 1); WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err); @@ -493,7 +493,7 @@ libpcap_write_interface_description_block(FILE *fp, } /* write os string if applicable */ - if ((strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) { + if ((os)&&(strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) { option.type = IDB_OS; option.value_length = (guint16)(strlen(filter) + 1); WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err); -- cgit v1.2.3