mirror of
https://github.com/vale981/spectrwm
synced 2025-03-05 09:51:38 -05:00
NUL terminate the strftime(3) buffer.
SUS says that if there wasn't enough space to copy the expanded format to the buffer, strftime(3) will not NUL terminate it. It would work on some implementations (eg on OpenBSD), though. Therefore, take advantage of the return value to prevent using the character array with unspecified contents with a very large clock format. Besides, the strlcat(3) call below relies on the destination buffer being NUL terminated. ok marco
This commit is contained in:
parent
684fc5a3a6
commit
20f6684161
1 changed files with 2 additions and 1 deletions
|
@ -1446,7 +1446,8 @@ bar_update(void)
|
|||
else {
|
||||
time(&tmt);
|
||||
localtime_r(&tmt, &tm);
|
||||
strftime(s, sizeof s, clock_format, &tm);
|
||||
len = strftime(s, sizeof s, clock_format, &tm);
|
||||
s[len] = '\0';
|
||||
strlcat(s, " ", sizeof s);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue