diff options
author | Anders Broman <anders.broman@ericsson.com> | 2012-02-21 13:59:08 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2012-02-21 13:59:08 +0000 |
commit | 3d0ac5c69ad5a9d133f8d25100735c49b99153c7 (patch) | |
tree | b51c8cca3a6442e02df8de2877fc2406f9bdbb3f /pcapio.c | |
parent | 5df11d41bb51aa76c28065f039ff03ec7c472628 (diff) |
Check if the string exists first.
svn path=/trunk/; revision=41109
Diffstat (limited to 'pcapio.c')
-rw-r--r-- | pcapio.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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); |