forked from osmocom/wireshark
Fix calculation of pading for if_filter_str.
svn path=/trunk/; revision=41351
This commit is contained in:
parent
995e10ef36
commit
a20cfcc745
6
pcapio.c
6
pcapio.c
|
@ -492,7 +492,7 @@ libpcap_write_interface_description_block(FILE *fp,
|
|||
}
|
||||
|
||||
/* write filter string if applicable
|
||||
* We only write version 1 of the fileter, libpcap string
|
||||
* We only write version 1 of the filter, libpcap string
|
||||
*/
|
||||
if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
|
||||
option.type = IDB_FILTER;
|
||||
|
@ -502,8 +502,8 @@ libpcap_write_interface_description_block(FILE *fp,
|
|||
/* The first byte of the Option Data keeps a code of the filter used, 0 = lipbpcap filter string */
|
||||
WRITE_DATA(fp, &padding, 1, *bytes_written, err);
|
||||
WRITE_DATA(fp, filter, strlen(filter) + 1, *bytes_written, err);
|
||||
if ((strlen(filter) + 1) % 4) {
|
||||
WRITE_DATA(fp, &padding, 4 - (strlen(filter) + 1) % 4 , *bytes_written, err);
|
||||
if ((strlen(filter) + 2) % 4) {
|
||||
WRITE_DATA(fp, &padding, 4 - (strlen(filter) + 2) % 4 , *bytes_written, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -834,7 +834,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
|
|||
*/
|
||||
if (option_content[0] == 0){
|
||||
wblock->data.if_descr.if_filter_str = g_strndup(option_content+1, oh.option_length-1);
|
||||
pcapng_debug1("pcapng_read_if_descr_block: if_filter_str %s", wblock->data.if_descr.if_filter_str);
|
||||
pcapng_debug2("pcapng_read_if_descr_block: if_filter_str %s oh.option_length %u", wblock->data.if_descr.if_filter_str, oh.option_length);
|
||||
}else if(option_content[0] == 1) {
|
||||
wblock->data.if_descr.bpf_filter_len = oh.option_length-1;
|
||||
wblock->data.if_descr.if_filter_bpf_bytes = g_malloc(oh.option_length-1);
|
||||
|
|
Loading…
Reference in New Issue