Revision 7267c094 libcacard/vcard_emul_nss.c

b/libcacard/vcard_emul_nss.c
94 94
    *certsp = NULL;
95 95
    *cert_lenp = NULL;
96 96
    *keysp = NULL;
97
    *certsp = (unsigned char **)qemu_malloc(sizeof(unsigned char *)*cert_count);
98
    *cert_lenp = (int *)qemu_malloc(sizeof(int)*cert_count);
99
    *keysp = (VCardKey **)qemu_malloc(sizeof(VCardKey *)*cert_count);
97
    *certsp = (unsigned char **)g_malloc(sizeof(unsigned char *)*cert_count);
98
    *cert_lenp = (int *)g_malloc(sizeof(int)*cert_count);
99
    *keysp = (VCardKey **)g_malloc(sizeof(VCardKey *)*cert_count);
100 100
    return PR_TRUE;
101 101
}
102 102

  
......
140 140
{
141 141
    VCardKey *key;
142 142

  
143
    key = (VCardKey *)qemu_malloc(sizeof(VCardKey));
143
    key = (VCardKey *)g_malloc(sizeof(VCardKey));
144 144
    key->slot = PK11_ReferenceSlot(slot);
145 145
    key->cert = CERT_DupCertificate(cert);
146 146
    /* NOTE: if we aren't logged into the token, this could return NULL */
......
244 244
    /* be able to handle larger keys if necessariy */
245 245
    bp = &buf[0];
246 246
    if (sizeof(buf) < signature_len) {
247
        bp = qemu_malloc(signature_len);
247
        bp = g_malloc(signature_len);
248 248
    }
249 249

  
250 250
    /*
......
348 348
    key->failedX509 = VCardEmulTrue;
349 349
cleanup:
350 350
    if (bp != buf) {
351
        qemu_free(bp);
351
        g_free(bp);
352 352
    }
353 353
    return ret;
354 354
}
......
382 382
      * to handle multiple guests from one process, then we would need to keep
383 383
      * a lot of extra state in our card structure
384 384
      * */
385
    pin_string = qemu_malloc(pin_len+1);
385
    pin_string = g_malloc(pin_len+1);
386 386
    memcpy(pin_string, pin, pin_len);
387 387
    pin_string[pin_len] = 0;
388 388

  
......
394 394
    rv = PK11_Authenticate(slot, PR_FALSE, pin_string);
395 395
    memset(pin_string, 0, pin_len);  /* don't let the pin hang around in memory
396 396
                                        to be snooped */
397
    qemu_free(pin_string);
397
    g_free(pin_string);
398 398
    if (rv == SECSuccess) {
399 399
        return VCARD7816_STATUS_SUCCESS;
400 400
    }
......
452 452
{
453 453
    VReaderEmul *new_reader_emul;
454 454

  
455
    new_reader_emul = (VReaderEmul *)qemu_malloc(sizeof(VReaderEmul));
455
    new_reader_emul = (VReaderEmul *)g_malloc(sizeof(VReaderEmul));
456 456

  
457 457
    new_reader_emul->slot = PK11_ReferenceSlot(slot);
458 458
    new_reader_emul->default_type = type;
......
473 473
        PK11_FreeSlot(vreader_emul->slot);
474 474
    }
475 475
    if (vreader_emul->type_params) {
476
        qemu_free(vreader_emul->type_params);
476
        g_free(vreader_emul->type_params);
477 477
    }
478
    qemu_free(vreader_emul);
478
    g_free(vreader_emul);
479 479
}
480 480

  
481 481
/*
......
658 658

  
659 659
    /* now create the card */
660 660
    card = vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count);
661
    qemu_free(certs);
662
    qemu_free(cert_len);
663
    qemu_free(keys);
661
    g_free(certs);
662
    g_free(cert_len);
663
    g_free(keys);
664 664

  
665 665
    return card;
666 666
}
......
947 947
            vreader_free(vreader);
948 948
            has_readers = PR_TRUE;
949 949
        }
950
        qemu_free(certs);
951
        qemu_free(cert_len);
952
        qemu_free(keys);
950
        g_free(certs);
951
        g_free(cert_len);
952
        g_free(keys);
953 953
    }
954 954

  
955 955
    /* if we aren't suppose to use hw, skip looking up hardware tokens */
......
1173 1173
            }
1174 1174
            opts->vreader = vreaderOpt;
1175 1175
            vreaderOpt = &vreaderOpt[opts->vreader_count];
1176
            vreaderOpt->name = qemu_strndup(name, name_length);
1177
            vreaderOpt->vname = qemu_strndup(vname, vname_length);
1176
            vreaderOpt->name = g_strndup(name, name_length);
1177
            vreaderOpt->vname = g_strndup(vname, vname_length);
1178 1178
            vreaderOpt->card_type = type;
1179 1179
            vreaderOpt->type_params =
1180
                qemu_strndup(type_params, type_params_length);
1180
                g_strndup(type_params, type_params_length);
1181 1181
            count = count_tokens(args, ',', ')') + 1;
1182 1182
            vreaderOpt->cert_count = count;
1183
            vreaderOpt->cert_name = (char **)qemu_malloc(count*sizeof(char *));
1183
            vreaderOpt->cert_name = (char **)g_malloc(count*sizeof(char *));
1184 1184
            for (i = 0; i < count; i++) {
1185 1185
                const char *cert = args;
1186 1186
                args = strpbrk(args, ",)");
1187
                vreaderOpt->cert_name[i] = qemu_strndup(cert, args - cert);
1187
                vreaderOpt->cert_name[i] = g_strndup(cert, args - cert);
1188 1188
                args = strip(args+1);
1189 1189
            }
1190 1190
            if (*args == ')') {
......
1211 1211
            args = strip(args+10);
1212 1212
            params = args;
1213 1213
            args = find_blank(args);
1214
            opts->hw_type_params = qemu_strndup(params, args-params);
1214
            opts->hw_type_params = g_strndup(params, args-params);
1215 1215
        /* db="/data/base/path" */
1216 1216
        } else if (strncmp(args, "db=", 3) == 0) {
1217 1217
            const char *db;
......
1222 1222
            args++;
1223 1223
            db = args;
1224 1224
            args = strpbrk(args, "\"\n");
1225
            opts->nss_db = qemu_strndup(db, args-db);
1225
            opts->nss_db = g_strndup(db, args-db);
1226 1226
            if (*args != 0) {
1227 1227
                args++;
1228 1228
            }

Also available in: Unified diff