xfree86: fix possible buffer overflow in xf86PrintBanner()
There's chance of buffer overflow happending due lack of zero-termination of printed string. Making sure the buffer is always propertly terminated. See: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1821 Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
329b7c8631
commit
3d21a15f54
|
@ -168,15 +168,14 @@ xf86PrintBanner(void)
|
||||||
name.version, name.machine);
|
name.version, name.machine);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
do {
|
do {
|
||||||
char buf[80];
|
|
||||||
int fd = open("/proc/cmdline", O_RDONLY);
|
int fd = open("/proc/cmdline", O_RDONLY);
|
||||||
|
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
|
char buf[82] = { 0 };
|
||||||
xf86ErrorFVerb(0, "Kernel command line: ");
|
xf86ErrorFVerb(0, "Kernel command line: ");
|
||||||
memset(buf, 0, 80);
|
while (read(fd, buf, sizeof(buf)-2) > 0) {
|
||||||
while (read(fd, buf, 80) > 0) {
|
|
||||||
xf86ErrorFVerb(0, "%.80s", buf);
|
xf86ErrorFVerb(0, "%.80s", buf);
|
||||||
memset(buf, 0, 80);
|
memset(buf, 0, sizeof(buf));
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue