(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/pcapng.c) |
| |
| 262 | | | pcapng_read_option(FILE_T fh, pcapng_t *pn, *oh, |
| 263 | | | char *content, int len, int *err, gchar **err_info _U_) |
| 264 | | | { |
| 265 | | | int bytes_read; |
| 266 | | | int block_read; |
| 267 | | | guint64 file_offset64; |
| 268 | | | |
| 269 | | | |
| 270 | | | |
| 271 | | | errno = WTAP_ERR_CANT_READ; |
| 272 | | | bytes_read = file_read(oh, 1, sizeof (*oh), fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 273 | | | if (bytes_read != sizeof (*oh)) { |
| 274 | | | pcapng_debug0("pcapng_read_option: failed to read option"); |
| 275 | | | *err = file_error(fh); |
| 276 | | | if (*err != 0) |
| 277 | | | return -1; |
| 278 | | | return 0; |
| 279 | | | } |
| 280 | | | block_read = sizeof (*oh); |
| 281 | | | if(pn->byte_swapped) { |
| 282 | | | oh->option_code = BSWAP16(oh->option_code); |
| 283 | | | oh->option_length = BSWAP16(oh->option_length); |
| 284 | | | } |
| 285 | | | |
| 286 | | | |
| 287 | | | if (oh->option_length > len) { |
| 288 | | | pcapng_debug2("pcapng_read_option: option_length %u larger than buffer (%u)", |
| 289 | | | oh->option_length, len); |
| 290 | | | return 0; |
| 291 | | | } |
| 292 | | | |
| 293 | | | |
| 294 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 295 | | | bytes_read = file_read(content, 1, oh->option_length, fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 296 | | | if (bytes_read != oh->option_length) { |
| 297 | | | pcapng_debug1("pcapng_read_if_descr_block: failed to read content of option %u", oh->option_code); |
| 298 | | | *err = file_error(fh); |
| 299 | | | if (*err != 0) |
| 300 | | | return -1; |
| 301 | | | return 0; |
| 302 | | | } |
| 303 | | | block_read += oh->option_length; |
| 304 | | | |
| 305 | | | |
| 306 | | | if( (oh->option_length % 4) != 0) { |
| 307 | | | file_offset64 = file_seek(fh, 4 - (oh->option_length % 4), SEEK_CUR, err);
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 308 | | | if (file_offset64 <= 0) { |
| 309 | | | if (*err != 0) |
| 310 | | | return -1; |
| 311 | | | return 0; |
| 312 | | | } |
| 313 | | | block_read += 4 - (oh->option_length % 4); |
| 314 | | | } |
| 315 | | | |
| 316 | | | return block_read; |
| 317 | | | } |
| |