Skip to content

Commit 3fde612

Browse files
authored
fixed gcc7 format-truncation warning (OpenSC#3069)
fixes OpenSC#1800
1 parent 19846e1 commit 3fde612

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/libopensc/pkcs15-openpgp.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
628628
LOG_FUNC_RETURN(ctx, r);
629629
}
630630

631+
// see https://stackoverflow.com/a/10536254 for explanation
632+
#define LEN_MAX_INT_AS_STR (3 * sizeof(int) + 2)
633+
631634
static int
632635
sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
633636
{
@@ -639,8 +642,8 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
639642
for (i = 1; i <= PGP_NUM_PRIVDO; i++) {
640643
sc_pkcs15_data_info_t dat_info;
641644
sc_pkcs15_object_t dat_obj;
642-
char name[8];
643-
char path[9];
645+
char name[6 + LEN_MAX_INT_AS_STR];
646+
char path[7 + LEN_MAX_INT_AS_STR];
644647
u8 content[254];
645648
memset(&dat_info, 0, sizeof(dat_info));
646649
memset(&dat_obj, 0, sizeof(dat_obj));

0 commit comments

Comments
 (0)