Make sure cmdline string always is null terminated, even if it is very long (Coverity CID 1164484).
This commit is contained in:
parent
1c9808ec42
commit
ae7c73ec7f
@ -303,9 +303,10 @@ int consolename(char *res, size_t rlen)
|
||||
perror("bootlogd: /proc/cmdline");
|
||||
} else {
|
||||
buf[0] = 0;
|
||||
if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0)
|
||||
if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0) {
|
||||
r = 0;
|
||||
else
|
||||
buf[sizeof(buf)-1] = 0; /* enforce null termination */
|
||||
} else
|
||||
perror("bootlogd: /proc/cmdline");
|
||||
close(fd);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user