mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-03-03 18:29:17 +01:00
util.c: Check for return codes of snprintf()
This commit is contained in:
parent
2f172e3227
commit
f77893a11c
19
util.c
19
util.c
@ -68,7 +68,10 @@ get_user_cfgfile_path(const char *common_path, const char *filename, const struc
|
||||
if ((userfile = malloc(len)) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
snprintf(userfile, len, "%s/%s", common_path, filename);
|
||||
int i = snprintf(userfile, len, "%s/%s", common_path, filename);
|
||||
if (i < 0 || i >= len) {
|
||||
return 0;
|
||||
}
|
||||
*fn = userfile;
|
||||
return 1;
|
||||
}
|
||||
@ -79,7 +82,10 @@ get_user_cfgfile_path(const char *common_path, const char *filename, const struc
|
||||
if ((userfile = malloc(len)) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
snprintf(userfile, len, "%s/.yubico/%s", user->pw_dir, filename);
|
||||
int i = snprintf(userfile, len, "%s/.yubico/%s", user->pw_dir, filename);
|
||||
if (i < 0 || i >= len) {
|
||||
return 0;
|
||||
}
|
||||
*fn = userfile;
|
||||
return 1;
|
||||
}
|
||||
@ -332,7 +338,14 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user,
|
||||
ret = AUTH_ERROR;
|
||||
goto out;
|
||||
}
|
||||
snprintf(userfile_pattern, len, "%s-*", userfile);
|
||||
|
||||
int i = snprintf(userfile_pattern, len, "%s-*", userfile);
|
||||
|
||||
if (i < 0 || i >= len) {
|
||||
D (debug_file, "Failed to format string correctly");
|
||||
ret = AUTH_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
r = glob(userfile_pattern, 0, NULL, &userfile_glob);
|
||||
globfree(&userfile_glob);
|
||||
|
Loading…
x
Reference in New Issue
Block a user