mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zkey: Fix APQN checking
An invalid APQN like '01.00xx' is not treated as invalid, but results in APQN '01.0000'. Fix the checking to treat such invalid APQNs as invalid. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
bfbf456b83
commit
d4cee7e65a
@@ -1106,6 +1106,7 @@ static int _keystore_apqn_check(const char *apqn, bool remove, bool UNUSED(set),
|
||||
int rc, card, domain;
|
||||
regmatch_t pmatch[1];
|
||||
regex_t reg_buf;
|
||||
unsigned int num;
|
||||
|
||||
*normalized = NULL;
|
||||
|
||||
@@ -1120,7 +1121,9 @@ static int _keystore_apqn_check(const char *apqn, bool remove, bool UNUSED(set),
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (sscanf(apqn, "%x.%x", &card, &domain) != 2) {
|
||||
if (sscanf(apqn, "%x.%x%n", &card, &domain, &num) != 2 ||
|
||||
num != strlen(apqn) || card < 0 || card > 0xff ||
|
||||
domain < 0 || domain > 0xFFFF) {
|
||||
warnx("the APQN '%s' is not valid", apqn);
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user