diff --git a/zkey/cca.c b/zkey/cca.c index f8c2c670..411a276c 100644 --- a/zkey/cca.c +++ b/zkey/cca.c @@ -558,7 +558,7 @@ int select_cca_adapter(struct cca_lib *cca, int card, int domain, bool verbose) { unsigned int adapters, adapter; char adapter_serialnr[9]; - char apqn_serialnr[9]; + char apqn_serialnr[SERIALNR_LENGTH]; char temp[10]; int rc, found = 0; diff --git a/zkey/utils.c b/zkey/utils.c index 4abc312b..f0050f28 100644 --- a/zkey/utils.c +++ b/zkey/utils.c @@ -224,10 +224,10 @@ out: } /** - * Gets the 8 character ASCII serial number string of an card from the sysfs. + * Gets the 8-16 character ASCII serial number string of an card from the sysfs. * * @param[in] card card number - * @param[out] serialnr Result buffer + * @param[out] serialnr Result buffer. Must be at least SERIALNR_LENGTH long. * @param[in] verbose if true, verbose messages are printed * * @returns 0 if the serial number was returned. -ENODEV if the APQN is not @@ -235,7 +235,7 @@ out: * -ENOTSUP if the serialnr sysfs attribute is not available, because * the zcrypt kernel module is on an older level. */ -int sysfs_get_serialnr(int card, char serialnr[9], bool verbose) +int sysfs_get_serialnr(int card, char *serialnr, bool verbose) { char *dev_path; int rc = 0; @@ -251,7 +251,8 @@ int sysfs_get_serialnr(int card, char serialnr[9], bool verbose) rc = -ENODEV; goto out; } - if (util_file_read_line(serialnr, 9, "%s/serialnr", dev_path) != 0) { + if (util_file_read_line(serialnr, SERIALNR_LENGTH, "%s/serialnr", + dev_path) != 0) { rc = -ENOTSUP; goto out; } diff --git a/zkey/utils.h b/zkey/utils.h index f361b21d..87bb104f 100644 --- a/zkey/utils.h +++ b/zkey/utils.h @@ -24,7 +24,9 @@ int sysfs_get_card_level(int card); enum card_type sysfs_get_card_type(int card); -int sysfs_get_serialnr(int card, char serialnr[9], bool verbose); +#define SERIALNR_LENGTH 17 + +int sysfs_get_serialnr(int card, char *serialnr, bool verbose); struct fw_version { unsigned int major;