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
							
								
									d10204372b
								
							
						
					
					
						commit
						1e4faee4e5
					
				|  | @ -168,15 +168,14 @@ xf86PrintBanner(void) | |||
|                            name.version, name.machine); | ||||
| #ifdef __linux__ | ||||
|             do { | ||||
|                 char buf[80]; | ||||
|                 int fd = open("/proc/cmdline", O_RDONLY); | ||||
| 
 | ||||
|                 if (fd != -1) { | ||||
|                     char buf[82] = { 0 }; | ||||
|                     xf86ErrorFVerb(0, "Kernel command line: "); | ||||
|                     memset(buf, 0, 80); | ||||
|                     while (read(fd, buf, 80) > 0) { | ||||
|                     while (read(fd, buf, sizeof(buf)-2) > 0) { | ||||
|                         xf86ErrorFVerb(0, "%.80s", buf); | ||||
|                         memset(buf, 0, 80); | ||||
|                         memset(buf, 0, sizeof(buf)); | ||||
|                     } | ||||
|                     close(fd); | ||||
|                 } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue