Don't assume we've read a line long enough to contain a magic number.

Check the length of the line first.

Bug: 13246
Change-Id: I906bb652594898061afb4b2cd4edb916af354161
Reviewed-on: https://code.wireshark.org/review/19273
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2016-12-14 14:42:54 -08:00
parent f78b60dce8
commit 5fdbb7a5ac
1 changed files with 2 additions and 1 deletions

View File

@ -95,7 +95,8 @@ wtap_open_return_val daintree_sna_open(wtap *wth, int *err, gchar **err_info)
}
/* check magic text */
if (memcmp(readLine, daintree_magic_text, DAINTREE_MAGIC_TEXT_SIZE) != 0)
if (strlen(readLine) >= DAINTREE_MAGIC_TEXT_SIZE &&
memcmp(readLine, daintree_magic_text, DAINTREE_MAGIC_TEXT_SIZE) != 0)
return WTAP_OPEN_NOT_MINE; /* not daintree format */
/* read second header line */