diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2014-03-19 22:38:31 +0100 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2014-03-20 08:39:00 +0000 |
commit | 4a51f624bf1028ddc7c73fd665ad292ff344060d (patch) | |
tree | 0ce7f6e1d6a8b84b2d6ac2fcb37d185a54d8828a /wiretap | |
parent | c14cc2f4edf8f88ce4bd64f8e6dff1dcccb07a14 (diff) |
use the correct end index when we loop over the open_info_arr
until recently, we always had a 0,0,0,... entry at the end of the array
that's gone now - which makes sense for people who register wiretap
plugins...
Change-Id: Id47dc4917481ffa8560e17b8740c2f9716bb8df1
Reviewed-on: https://code.wireshark.org/review/747
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/file_access.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 816ae66065..9a43ed2c5c 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -388,7 +388,7 @@ static void set_heuristic_routine(void) { guint i; g_assert(open_info_arr != NULL); - for (i = 0; i < open_info_arr->len - 1; i++) { + for (i = 0; i < open_info_arr->len; i++) { if (open_routines[i].type == OPEN_INFO_HEURISTIC) { heuristic_open_routine_idx = i; break; @@ -459,7 +459,7 @@ void wtap_deregister_open_info(const gchar *name) { return; } - for (i = 0; i < open_info_arr->len - 1; i++) { + for (i = 0; i < open_info_arr->len; i++) { if (open_routines[i].name && strcmp(open_routines[i].name, name) == 0) { open_info_arr = g_array_remove_index(open_info_arr, i); set_heuristic_routine(); @@ -482,7 +482,7 @@ gboolean wtap_has_open_info(const gchar *name) { } - for (i = 0; i < open_info_arr->len - 1; i++) { + for (i = 0; i < open_info_arr->len; i++) { if (open_routines[i].name && strcmp(open_routines[i].name, name) == 0) { return TRUE; } @@ -522,7 +522,7 @@ unsigned int open_info_name_to_type(const char *name) if (!name) return WTAP_TYPE_AUTO; - for (i = 0; i < open_info_arr->len - 1; i++) { + for (i = 0; i < open_info_arr->len; i++) { if (open_routines[i].name != NULL && strcmp(name, open_routines[i].name) == 0) return i+1; @@ -833,7 +833,7 @@ wtap* wtap_open_offline(const char *filename, unsigned int type, int *err, char } /* Try all file types that support magic numbers */ - for (i = 0; i < open_info_arr->len - 1; i++) { + for (i = 0; i < open_info_arr->len; i++) { /* Seek back to the beginning of the file; the open routine for the previous file type may have left the file position somewhere other than the beginning, and the @@ -875,7 +875,7 @@ wtap* wtap_open_offline(const char *filename, unsigned int type, int *err, char extension = get_file_extension(filename); if (extension != NULL) { /* Yes - try the heuristic types that use that extension first. */ - for (i = heuristic_open_routine_idx; i < open_info_arr->len - 1; i++) { + for (i = heuristic_open_routine_idx; i < open_info_arr->len; i++) { /* Does this type use that extension? */ if (heuristic_uses_extension(i, extension)) { /* Yes. */ @@ -913,7 +913,7 @@ wtap* wtap_open_offline(const char *filename, unsigned int type, int *err, char } /* Now try the ones that don't use it. */ - for (i = heuristic_open_routine_idx; i < open_info_arr->len - 1; i++) { + for (i = heuristic_open_routine_idx; i < open_info_arr->len; i++) { /* Does this type use that extension? */ if (!heuristic_uses_extension(i, extension)) { /* No. */ @@ -952,7 +952,7 @@ wtap* wtap_open_offline(const char *filename, unsigned int type, int *err, char g_free(extension); } else { /* No - try all the heuristics types in order. */ - for (i = heuristic_open_routine_idx; i < open_info_arr->len - 1; i++) { + for (i = heuristic_open_routine_idx; i < open_info_arr->len; i++) { if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) { /* I/O error - give up */ |