Skip to content

Commit c06768a

Browse files
authtok: Set Kerberos passkey PIN to NULL when UV is false
1 parent c804df6 commit c06768a

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/util/authtok-utils.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,8 @@ errno_t sss_auth_pack_passkey_blob(uint8_t *buf,
122122
/* Add provided PIN */
123123
if (pin != NULL) {
124124
pin_len = strlen(pin) + 1;
125-
/* User verification is false */
126-
} else {
127-
pin = "";
128-
pin_len = 0;
125+
memcpy(buf + len, pin, pin_len);
129126
}
130-
memcpy(buf + len, pin, pin_len);
131127

132128
return EOK;
133129
}

src/util/authtok.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,16 @@ errno_t sss_auth_unpack_passkey_blob(TALLOC_CTX *mem_ctx,
716716
}
717717
len += strlen(key) + 1;
718718

719-
pin = talloc_strdup(mem_ctx, (const char *) blob + len);
720-
if (pin == NULL) {
721-
DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup pin failed.\n");
722-
talloc_free(prompt);
723-
talloc_free(key);
724-
return ENOMEM;
719+
if ((strcasecmp(prompt, "true") == 0)) {
720+
pin = talloc_strdup(mem_ctx, (const char *) blob + len);
721+
if (pin == NULL) {
722+
DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup pin failed.\n");
723+
talloc_free(prompt);
724+
talloc_free(key);
725+
return ENOMEM;
726+
}
727+
} else {
728+
pin = NULL;
725729
}
726730

727731
*_prompt = prompt;
@@ -842,7 +846,9 @@ errno_t sss_authtok_get_passkey(TALLOC_CTX *mem_ctx,
842846
goto done;
843847
}
844848

845-
pin_len = strlen(pin);
849+
if (pin != NULL) {
850+
pin_len = strlen(pin);
851+
}
846852

847853
*_prompt = prompt;
848854
*_key = key;

0 commit comments

Comments
 (0)