diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-12-14 15:02:33 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-12-14 23:03:04 +0000 |
commit | 1afbab69956c32b341001dd20ff667036fe1f8f5 (patch) | |
tree | 29e2ac63ed64a7fc6bc658b3b47b5abdcbc9652e /wiretap/daintree-sna.c | |
parent | 5fdbb7a5ac8a0a68b42264bde094b90d455350e5 (diff) |
Just use strncmp() to check the prefix of the file's first line.
Bug: 13246
Change-Id: I9df35596aa8dcb937f6a03cf60b5d0fbe9dce1ec
Reviewed-on: https://code.wireshark.org/review/19276
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/daintree-sna.c')
-rw-r--r-- | wiretap/daintree-sna.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c index dfb51c27a3..3deca1dff7 100644 --- a/wiretap/daintree-sna.c +++ b/wiretap/daintree-sna.c @@ -62,10 +62,9 @@ typedef struct daintree_sna_header { #define DAINTREE_SNA_HEADER_SIZE 2 #define FCS_LENGTH 2 -static const char daintree_magic_text[] = -{ '#', 'F', 'o', 'r', 'm', 'a', 't', '=' }; +static const char daintree_magic_text[] = "#Format="; -#define DAINTREE_MAGIC_TEXT_SIZE (sizeof daintree_magic_text) +#define DAINTREE_MAGIC_TEXT_SIZE (sizeof daintree_magic_text - 1) #define DAINTREE_MAX_LINE_SIZE 512 #define READDATA_BUF_SIZE (DAINTREE_MAX_LINE_SIZE/2) #define READDATA_MAX_FIELD_SIZE "255" /* DAINTREE_MAX_LINE_SIZE/2 -1 */ @@ -95,8 +94,7 @@ wtap_open_return_val daintree_sna_open(wtap *wth, int *err, gchar **err_info) } /* check magic text */ - if (strlen(readLine) >= DAINTREE_MAGIC_TEXT_SIZE && - memcmp(readLine, daintree_magic_text, DAINTREE_MAGIC_TEXT_SIZE) != 0) + if (strncmp(readLine, daintree_magic_text, DAINTREE_MAGIC_TEXT_SIZE) != 0) return WTAP_OPEN_NOT_MINE; /* not daintree format */ /* read second header line */ |