Skip to content

Commit

Permalink
fixed gcc7 format-truncation warning (#3069)
Browse files Browse the repository at this point in the history
fixes #1800
  • Loading branch information
frankmorgner committed Mar 18, 2024
1 parent 19846e1 commit 3fde612
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libopensc/pkcs15-openpgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
LOG_FUNC_RETURN(ctx, r);
}

// see https://stackoverflow.com/a/10536254 for explanation
#define LEN_MAX_INT_AS_STR (3 * sizeof(int) + 2)

static int
sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
{
Expand All @@ -639,8 +642,8 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
for (i = 1; i <= PGP_NUM_PRIVDO; i++) {
sc_pkcs15_data_info_t dat_info;
sc_pkcs15_object_t dat_obj;
char name[8];
char path[9];
char name[6 + LEN_MAX_INT_AS_STR];
char path[7 + LEN_MAX_INT_AS_STR];
u8 content[254];
memset(&dat_info, 0, sizeof(dat_info));
memset(&dat_obj, 0, sizeof(dat_obj));
Expand Down

0 comments on commit 3fde612

Please sign in to comment.