diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-01-01 13:04:44 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-01-01 21:36:58 +0000 |
commit | e12270a730a60636ad36c06957b7e1f687c562a7 (patch) | |
tree | fe3302eba8155508dafc2859b557843962533719 /ui/cli | |
parent | bac10e586948943f51f36cdad59b409c7de825c3 (diff) |
Limit the maximum *file* name length for exported objects.
Limiting the maximum *path* name length is bogus; if the user wants to
store the file in some directory deep under the root (UN*X) or the root
of the drive (Windows), that's their choice - don't prevent them from
saving in a directory with a path longer than some maximum or limit the
file name based on the length of the path leading up to it.
Limiting the maximum *file* name is presumably to cope with, for
example, HTTP objects with a URL that had a very long query component,
so it makes sense.
Change-Id: Idfc7de8124ee80bdd4950341ff2239834eb9f6f6
Reviewed-on: https://code.wireshark.org/review/31295
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/cli')
-rw-r--r-- | ui/cli/tap-exportobject.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/ui/cli/tap-exportobject.c b/ui/cli/tap-exportobject.c index e804e19857..0766da779b 100644 --- a/ui/cli/tap-exportobject.c +++ b/ui/cli/tap-exportobject.c @@ -120,37 +120,31 @@ eo_draw(void *tapdata) } } - if ((strlen(save_in_path) < EXPORT_OBJECT_MAXFILELEN)) { - while (slist) { - entry = (export_object_entry_t *)slist->data; - do { - g_free(save_as_fullpath); - if (entry->filename) { - safe_filename = eo_massage_str(entry->filename, - EXPORT_OBJECT_MAXFILELEN - strlen(save_in_path), count); - } else { - char generic_name[EXPORT_OBJECT_MAXFILELEN+1]; - const char *ext; - ext = eo_ct2ext(entry->content_type); - g_snprintf(generic_name, sizeof(generic_name), - "object%u%s%s", entry->pkt_num, ext ? "." : "", ext ? ext : ""); - safe_filename = eo_massage_str(generic_name, - EXPORT_OBJECT_MAXFILELEN - strlen(save_in_path), count); - } - save_as_fullpath = g_build_filename(save_in_path, safe_filename->str, NULL); - g_string_free(safe_filename, TRUE); - } while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000); - count = 0; - if (!eo_save_entry(save_as_fullpath, entry, TRUE)) - all_saved = FALSE; + while (slist) { + entry = (export_object_entry_t *)slist->data; + do { g_free(save_as_fullpath); - save_as_fullpath = NULL; - slist = slist->next; - } - } - else - { - all_saved = FALSE; + if (entry->filename) { + safe_filename = eo_massage_str(entry->filename, + EXPORT_OBJECT_MAXFILELEN, count); + } else { + char generic_name[EXPORT_OBJECT_MAXFILELEN+1]; + const char *ext; + ext = eo_ct2ext(entry->content_type); + g_snprintf(generic_name, sizeof(generic_name), + "object%u%s%s", entry->pkt_num, ext ? "." : "", ext ? ext : ""); + safe_filename = eo_massage_str(generic_name, + EXPORT_OBJECT_MAXFILELEN, count); + } + save_as_fullpath = g_build_filename(save_in_path, safe_filename->str, NULL); + g_string_free(safe_filename, TRUE); + } while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000); + count = 0; + if (!eo_save_entry(save_as_fullpath, entry, TRUE)) + all_saved = FALSE; + g_free(save_as_fullpath); + save_as_fullpath = NULL; + slist = slist->next; } if (!all_saved) |