mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Make sure we don't read too much
This commit is contained in:
		
							parent
							
								
									236ebeeb68
								
							
						
					
					
						commit
						ce98162ed2
					
				
					 2 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -53,6 +53,7 @@ struct impl {
 | 
			
		|||
static int check_cmdline(struct pw_impl_client *client, int pid, const char *str)
 | 
			
		||||
{
 | 
			
		||||
	char path[2048];
 | 
			
		||||
	ssize_t len;
 | 
			
		||||
	int fd;
 | 
			
		||||
 | 
			
		||||
	sprintf(path, "/proc/%u/cmdline", pid);
 | 
			
		||||
| 
						 | 
				
			
			@ -61,10 +62,11 @@ static int check_cmdline(struct pw_impl_client *client, int pid, const char *str
 | 
			
		|||
	if (fd < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
 | 
			
		||||
	if (read(fd, path, 1024) <= 0) {
 | 
			
		||||
	if ((len = read(fd, path, sizeof(path)-1)) < 0) {
 | 
			
		||||
		close(fd);
 | 
			
		||||
		return -EIO;
 | 
			
		||||
		return -errno;
 | 
			
		||||
	}
 | 
			
		||||
	path[len] = '\0';
 | 
			
		||||
 | 
			
		||||
	if (strcmp(path, str) == 0) {
 | 
			
		||||
		close(fd);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2708,7 +2708,7 @@ static void do_input(void *data, int fd, uint32_t mask)
 | 
			
		|||
 | 
			
		||||
	if (mask & SPA_IO_IN) {
 | 
			
		||||
		while (true) {
 | 
			
		||||
			r = read(fd, buf, sizeof(buf));
 | 
			
		||||
			r = read(fd, buf, sizeof(buf)-1);
 | 
			
		||||
			if (r < 0) {
 | 
			
		||||
				if (errno == EAGAIN)
 | 
			
		||||
					continue;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue