summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2005-09-20 08:31:27 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2005-09-20 08:31:27 +0000
commitcff33b6413b03978d6289542f9aec790f0785783 (patch)
tree34abf1d042d90229f84c4bd1590f9488cf6d4806 /modules
parentccfa4297f4081a42919afd793a615d09b965442c (diff)
Relevant BUGIDs: none
Purpose of commit: bugfix Commit summary: --------------- Fix missing NULL pointer check and us asprintf instead of malloc/snprintf (from Dmitry V. Levin).
Diffstat (limited to 'modules')
-rw-r--r--modules/pam_userdb/pam_userdb.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c
index 188726f7..f584a438 100644
--- a/modules/pam_userdb/pam_userdb.c
+++ b/modules/pam_userdb/pam_userdb.c
@@ -175,9 +175,10 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode,
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
if (ctrl & PAM_KEY_ONLY_ARG) {
- key.dptr = malloc(strlen(user) + 1 + strlen(pass) + 1);
- sprintf(key.dptr, "%s-%s", user, pass);
- key.dsize = strlen(key.dptr);
+ if (asprintf(&key.dptr, "%s-%s", user, pass) < 0)
+ key.dptr = NULL;
+ else
+ key.dsize = strlen(key.dptr);
} else {
key.dptr = x_strdup(user);
key.dsize = strlen(user);