(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/snoop.c) |
| |
| 178 | | | int snoop_open(wtap *wth, int *err, gchar **err_info) |
| 179 | | | { |
| 180 | | | int bytes_read; |
| 181 | | | char magic[sizeof snoop_magic]; |
| 182 | | | struct snoop_hdr hdr; |
| 183 | | | struct snooprec_hdr rec_hdr; |
| 184 | | | guint padbytes; |
| 185 | | | gboolean is_shomiti; |
| 186 | | | static const int snoop_encap[] = { |
| 187 | | | WTAP_ENCAP_ETHERNET, |
| 188 | | | WTAP_ENCAP_UNKNOWN, |
| 189 229 |  | | [ Lines 189 to 229 omitted. ] |
| 230 | | | WTAP_ENCAP_TOKEN_RING, |
| 231 | | | WTAP_ENCAP_UNKNOWN, |
| 232 | | | WTAP_ENCAP_UNKNOWN, |
| 233 | | | WTAP_ENCAP_UNKNOWN, |
| 234 | | | WTAP_ENCAP_IEEE_802_11_WITH_RADIO, |
| 235 | | | }; |
| 236 | | | #define NUM_SHOMITI_ENCAPS (sizeof shomiti_encap / sizeof shomiti_encap[0]) |
| 237 | | | int file_encap; |
| 238 | | | |
| 239 | | | |
| 240 | | | errno = WTAP_ERR_CANT_READ; |
| 241 | | | bytes_read = file_read(magic, 1, sizeof magic, wth->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))) |
| |
|
| 242 | | | if (bytes_read != sizeof magic) { |
| 243 | | | *err = file_error(wth->fh); |
| 244 | | | if (*err != 0) |
| 245 | | | return -1; |
| 246 | | | return 0; |
| 247 | | | } |
| 248 | | | wth->data_offset += sizeof magic; |
| 249 | | | |
| 250 | | | if (memcmp(magic, snoop_magic, sizeof snoop_magic) != 0) { |
| 251 | | | return 0; |
| 252 | | | } |
| 253 | | | |
| 254 | | | |
| 255 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 256 | | | bytes_read = file_read(&hdr, 1, sizeof hdr, wth->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))) |
| |
|
| 257 | | | if (bytes_read != sizeof hdr) { |
| 258 | | | *err = file_error(wth->fh); |
| 259 | | | if (*err != 0) |
| 260 | | | return -1; |
| 261 | | | return 0; |
| 262 | | | } |
| 263 | | | wth->data_offset += sizeof hdr; |
| 264 | | | |
| 265 | | | |
| 266 | | | |
| 267 | | | |
| 268 | | | hdr.version = g_ntohl(hdr.version);
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 269 | | | switch (hdr.version) { |
| 270 | | | |
| 271 | | | case 2: |
| 272 | | | |
| 273 | | | |
| 274 | | | case 3: |
| 275 | | | case 4: |
| 276 | | | case 5: |
| 277 | | | break; |
| 278 | | | |
| 279 | | | default: |
| 280 | | | *err = WTAP_ERR_UNSUPPORTED; |
| 281 | | | *err_info = g_strdup_printf("snoop: version %u unsupported", hdr.version); |
| 282 | | | return -1; |
| 283 | | | } |
| 284 | | | |
| 285 | | | |
| 286 | | | |
| 287 | | | |
| 288 | | | |
| 289 | | | |
| 290 | | | |
| 291 | | | |
| 292 | | | |
| 293 302 |  | | [ Lines 293 to 302 omitted. ] |
| 303 | | | |
| 304 | | | |
| 305 | | | |
| 306 | | | |
| 307 | | | |
| 308 | | | |
| 309 | | | |
| 310 | | | |
| 311 | | | |
| 312 | | | |
| 313 | | | is_shomiti = FALSE; |
| 314 | | | |
| 315 | | | |
| 316 | | | errno = WTAP_ERR_CANT_READ; |
| 317 | | | bytes_read = file_read(&rec_hdr, 1, sizeof rec_hdr, wth->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))) |
| |
|
| 318 | | | if (bytes_read != sizeof rec_hdr) { |
| 319 | | | *err = file_error(wth->fh); |
| 320 | | | if (*err == 0 && bytes_read != 0) |
| 321 | | | *err = WTAP_ERR_SHORT_READ; |
| 322 | | | if (*err != 0) { |
| 323 | | | |
| 324 | | | |
| 325 | | | |
| 326 | | | return -1; |
| 327 | | | } |
| 328 | | | |
| 329 | | | |
| 330 | | | |
| 331 | | | |
| 332 | | | |
| 333 | | | |
| 334 | | | |
| 335 | | | |
| 336 | | | |
| 337 | | | |
| 338 | | | |
| 339 | | | } else { |
| 340 | | | |
| 341 | | | |
| 342 | | | |
| 343 | | | |
| 344 | | | |
| 345 | | | |
| 346 | | | |
| 347 | | | |
| 348 | | | |
| 349 | | | if (g_ntohl(rec_hdr.rec_len) >
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 350 | | | (sizeof rec_hdr + g_ntohl(rec_hdr.incl_len))) {
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 351 | | | |
| 352 | | | |
| 353 | | | |
| 354 | | | padbytes = g_ntohl(rec_hdr.rec_len) -
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 355 | | | ((guint)sizeof rec_hdr + g_ntohl(rec_hdr.incl_len));
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 356 | | | |
| 357 | | | |
| 358 | | | |
| 359 | | | |
| 360 | | | is_shomiti = |
| 361 | | | (padbytes >= sizeof (struct shomiti_trailer)); |
| 362 | | | } |
| 363 | | | } |
| 364 | | | |
| 365 | | | |
| 366 | | | |
| 367 | | | |
| 368 | | | if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1)
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
| 369 | | | return -1; |
| 370 | | | |
| 371 | | | hdr.network = g_ntohl(hdr.network);
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 372 | | | if (is_shomiti) { |
| 373 | | | if (hdr.network >= NUM_SHOMITI_ENCAPS
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/snoop.c |
| |
236 | #define NUM_SHOMITI_ENCAPS (sizeof shomiti_encap / sizeof shomiti_encap[0]) |
| |
|
| 374 | | | || shomiti_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { |
| 375 | | | *err = WTAP_ERR_UNSUPPORTED_ENCAP; |
| 376 | | | *err_info = g_strdup_printf("snoop: Shomiti network type %u unknown or unsupported", |
| 377 | | | hdr.network); |
| 378 | | | return -1; |
| 379 | | | } |
| 380 | | | file_encap = shomiti_encap[hdr.network]; |
| 381 | | | |
| 382 | | | |
| 383 | | | wth->file_type = WTAP_FILE_SHOMITI; |
| 384 | | | } else { |
| 385 | | | if (hdr.network >= NUM_SNOOP_ENCAPS
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/snoop.c |
| |
214 | #define NUM_SNOOP_ENCAPS (sizeof snoop_encap / sizeof snoop_encap[0]) |
| |
|
| 386 | | | || snoop_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { |
| 387 | | | *err = WTAP_ERR_UNSUPPORTED_ENCAP; |
| 388 | | | *err_info = g_strdup_printf("snoop: network type %u unknown or unsupported", |
| 389 | | | hdr.network); |
| 390 | | | return -1; |
| 391 | | | } |
| 392 | | | file_encap = snoop_encap[hdr.network]; |
| 393 | | | |
| 394 | | | |
| 395 | | | wth->file_type = WTAP_FILE_SNOOP; |
| 396 | | | } |
| 397 | | | |
| 398 | | | |
| 399 | | | |
| 400 | | | |
| 401 | | | |
| 402 | | | |
| 403 | | | wth->subtype_read = snoop_read; |
| 404 | | | wth->subtype_seek_read = snoop_seek_read; |
| 405 | | | wth->file_encap = file_encap; |
| 406 | | | wth->snapshot_length = 0; |
| 407 | | | wth->tsprecision = WTAP_FILE_TSPREC_USEC; |
| 408 | | | return 1; |
| 409 | | | } |
| |