diff options
author | Dario Lombardo <lomato@gmail.com> | 2019-07-04 15:18:36 +0200 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2019-07-05 12:26:44 +0000 |
commit | aa434673bfd2f45f26394c828558dd0bb9aff718 (patch) | |
tree | 30e71188d2df7a9c3b587a21d85f71686e4d9874 /ui/cli | |
parent | 85ca8d7fce3d10d3022b0a478c0edfd3e9eeb13e (diff) |
credentials: don't use wmem file scope but a local copy.
Change-Id: I44ca95bffd682a7f2e83b71400937a949f5886ea
Reviewed-on: https://code.wireshark.org/review/33844
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Diffstat (limited to 'ui/cli')
-rw-r--r-- | ui/cli/tap-credentials.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ui/cli/tap-credentials.c b/ui/cli/tap-credentials.c index 46c1b31ae0..051d44fb77 100644 --- a/ui/cli/tap-credentials.c +++ b/ui/cli/tap-credentials.c @@ -28,12 +28,37 @@ void register_tap_listener_credentials(void); wmem_array_t* credentials = NULL; +static tap_credential_t* tap_credential_clone(tap_credential_t* auth) +{ + tap_credential_t* clone = wmem_new0(NULL, tap_credential_t); + clone->num = auth->num; + clone->username_num = auth->username_num; + clone->password_hf_id = auth->password_hf_id; + if (auth->username) + clone->username = wmem_strdup(NULL, auth->username); + clone->proto = auth->proto; + if (auth->info) + clone->info = wmem_strdup(NULL, auth->info); + return clone; +} + static tap_packet_status credentials_packet(void *p _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri) { - wmem_array_append(credentials, (void*)pri, 1); + tap_credential_t* clone = tap_credential_clone((tap_credential_t*)pri); + wmem_array_append(credentials, (void*)clone, 1); return TAP_PACKET_REDRAW; } +static void credentials_reset(void* p) +{ + if (!p) + return; + tap_credential_t* auth = (tap_credential_t*)p; + wmem_free(NULL, auth->username); + wmem_free(NULL, auth->info); + wmem_free(NULL, auth); +} + static void credentials_draw(void *p _U_) { printf("===================================================================\n"); @@ -51,7 +76,7 @@ static void credentials_init(const char *opt_arg _U_, void *userdata _U_) GString* error_string; error_string = register_tap_listener("credentials", NULL, NULL, TL_REQUIRES_NOTHING, - NULL, credentials_packet, credentials_draw, NULL); + credentials_reset, credentials_packet, credentials_draw, NULL); if (error_string) { /* error, we failed to attach to the tap. clean up */ |