Skip to content

Commit d8cc2bf

Browse files
poetteringkeszybz
authored andcommitted
pam-util: fix pam_syslog_pam_error() format string
To cut off a string at some position we must set the "precision" not the field width in format strings. This led to some assert()s being hit where they really should not be. (cherry picked from commit f200d6c) (cherry picked from commit 1c47432)
1 parent 85ee15a commit d8cc2bf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/shared/pam-util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ int pam_syslog_pam_error(pam_handle_t *handle, int level, int error, const char
3737
pamerr = "n/a"; /* We cannot have any formatting chars */
3838

3939
char buf[p - format + strlen(pamerr) + 1];
40-
xsprintf(buf, "%*s%s", (int)(p - format), format, pamerr);
40+
xsprintf(buf, "%.*s%s", (int)(p - format), format, pamerr);
41+
4142
DISABLE_WARNING_FORMAT_NONLITERAL;
4243
pam_vsyslog(handle, level, buf, ap);
4344
REENABLE_WARNING;

0 commit comments

Comments
 (0)