Skip to content

Commit

Permalink
libcacard: Fix unchecked strdup() by converting to g_strdup()
Browse files Browse the repository at this point in the history
Note that we already free with g_free().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Markus Armbruster authored and stefanhaRH committed Jan 30, 2013
1 parent 40a50b0 commit be168af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libcacard/vcard_emul_nss.c
Expand Up @@ -454,7 +454,7 @@ vreader_emul_new(PK11SlotInfo *slot, VCardEmulType type, const char *params)

new_reader_emul->slot = PK11_ReferenceSlot(slot);
new_reader_emul->default_type = type;
new_reader_emul->type_params = strdup(params);
new_reader_emul->type_params = g_strdup(params);
new_reader_emul->present = PR_FALSE;
new_reader_emul->series = 0;
new_reader_emul->saved_vcard = NULL;
Expand Down Expand Up @@ -997,7 +997,7 @@ vcard_emul_init(const VCardEmulOptions *options)
/* We should control this with options. For now we mirror out any
* removable hardware slot */
default_card_type = options->hw_card_type;
default_type_params = strdup(options->hw_type_params);
default_type_params = g_strdup(options->hw_type_params);

SECMOD_GetReadLock(module_lock);
for (mlp = module_list; mlp; mlp = mlp->next) {
Expand Down
2 changes: 1 addition & 1 deletion libcacard/vreader.c
Expand Up @@ -49,7 +49,7 @@ vreader_new(const char *name, VReaderEmul *private,
reader = (VReader *)g_malloc(sizeof(VReader));
qemu_mutex_init(&reader->lock);
reader->reference_count = 1;
reader->name = name ? strdup(name) : NULL;
reader->name = g_strdup(name);
reader->card = NULL;
reader->id = (vreader_id_t)-1;
reader->reader_private = private;
Expand Down
4 changes: 2 additions & 2 deletions libcacard/vscclient.c
Expand Up @@ -503,8 +503,8 @@ main(
command_line_options = vcard_emul_options(emul_args);
}

qemu_host = strdup(argv[argc - 2]);
qemu_port = strdup(argv[argc - 1]);
qemu_host = g_strdup(argv[argc - 2]);
qemu_port = g_strdup(argv[argc - 1]);
sock = connect_to_qemu(qemu_host, qemu_port);
if (sock == -1) {
fprintf(stderr, "error opening socket, exiting.\n");
Expand Down

0 comments on commit be168af

Please sign in to comment.