I found a few issues with gtkcard, please review attached patch. 1.) enrollInfo in CreateWindows.c is malloc'ed and filled but never used.
2.) P11.c has several off by one error. one is fixed with setting j to 31, but two lines below that tokenString[32] is also off by one. 3.) newObject is not free()d in error handling parts. malloc'ing it later solves that issue. Regards, Andreas
Index: src/CreateWindows.c =================================================================== --- src/CreateWindows.c (revision 100) +++ src/CreateWindows.c (working copy) @@ -732,8 +732,6 @@ GtkWidget *userLabel; GtkWidget *label; - pEnrollUserInfo enrollInfo = malloc(sizeof(enrollUserInfo)); - // Labels, Buttons and Combos label = gtk_label_new("NOTE: You need to do this as root!"); comboLabel = gtk_label_new("Please select smartcard reader:"); @@ -754,9 +752,6 @@ globalState.enrollCombo = gtk_combo_new(); - enrollInfo->userName = (GtkEntry *) userEntry; - enrollInfo->fileName = (GtkEntry *) fileEntry; - // The window and the container table enrollUserWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); containerTable = gtk_table_new(7, 3, TRUE); Index: src/P11.c =================================================================== --- src/P11.c (revision 100) +++ src/P11.c (working copy) @@ -85,7 +85,7 @@ DEBUG("Slot %ld: %s\n", pSlotList[i], infoString); if (rv != CKR_TOKEN_NOT_PRESENT) { - CK_BYTE j = 32; + CK_BYTE j = 31; strncpy(tokenString, (char *)tokenInfo.label, 32); tokenString[32] = '\0'; DEBUG("token: %s\n", tokenString); @@ -274,9 +274,6 @@ pObjectInfo newObject; int nb_objects; - newObject = malloc(sizeof(objectInfo)); - ASSERT(newObject != NULL_PTR, "Could not allocate memory", -1); - pValueTemplate[0].type = CKA_VALUE; pValueTemplate[0].pValue = NULL_PTR; pValueTemplate[0].ulValueLen = 0; @@ -325,6 +322,9 @@ /* make sure the string is null-terminated */ application[pValueTemplate[1].ulValueLen] = '\0'; + newObject = malloc(sizeof(objectInfo)); + ASSERT(newObject != NULL_PTR, "Could not allocate memory", -1); + newObject->size = pValueTemplate[0].ulValueLen; newObject->ohHandle = ohObject;
_______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel