mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: don't overrun the input array
Read one byte less than the size of the buffer so that we still have room in the buffer to append the 0 byte.
This commit is contained in:
		
							parent
							
								
									d2d01b43d3
								
							
						
					
					
						commit
						f95ecf95ba
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -63,11 +63,11 @@ static char *read_file(const char *name, char *buffer, size_t len)
 | 
				
			||||||
	if ((fd = open(name, O_RDONLY | O_CLOEXEC, 0)) < 0)
 | 
						if ((fd = open(name, O_RDONLY | O_CLOEXEC, 0)) < 0)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((n = read(fd, buffer, len)) < 0) {
 | 
						if ((n = read(fd, buffer, len-1)) < 0) {
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	buffer[n] = 0;
 | 
						buffer[n] = '\0';
 | 
				
			||||||
	close(fd);
 | 
						close(fd);
 | 
				
			||||||
	return buffer;
 | 
						return buffer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue