mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:35:42 +01:00
alsactl: sprintf to snprintf prevent buffer overflow
sprintf() is a bit dangerous unless you explicitly know your type size and want to keep it in sync always. Its safer to just use snprintf() and ensure your string doesn't overflow and is NULL terminated. Signed-off-by: Doug Goldstein <cardoe@cardoe.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
b4f34ac260
commit
888275e66c
1 changed files with 2 additions and 2 deletions
|
@ -53,9 +53,9 @@ static int state_lock_(const char *file, int lock, int timeout)
|
|||
lck.l_len = 11;
|
||||
lck.l_pid = 0;
|
||||
if (lock) {
|
||||
sprintf(lcktxt, "%10li\n", (long)getpid());
|
||||
snprintf(lcktxt, sizeof(lcktxt), "%10li\n", (long)getpid());
|
||||
} else {
|
||||
sprintf(lcktxt, "%10s\n", "");
|
||||
snprintf(lcktxt, sizeof(lcktxt), "%10s\n", "");
|
||||
}
|
||||
while (fd < 0 && timeout-- > 0) {
|
||||
fd = open(nfile, O_RDWR);
|
||||
|
|
Loading…
Reference in a new issue