ipc: do not use fscanf with trailing \n
If the stream is not closed, then this winds up hanging forever. So remove the trailing \n\n and check manually after. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									66ed611bd0
								
							
						
					
					
						commit
						457f96b65e
					
				@ -92,8 +92,10 @@ static int userspace_set_device(struct wgdevice *dev)
 | 
			
		||||
	fprintf(f, "\n");
 | 
			
		||||
	fflush(f);
 | 
			
		||||
 | 
			
		||||
	if (fscanf(f, "errno=%d\n\n", &ret) != 1)
 | 
			
		||||
	if (fscanf(f, "errno=%d", &ret) != 1)
 | 
			
		||||
		ret = errno ? -errno : -EPROTO;
 | 
			
		||||
	if (getc(f) != '\n' || getc(f) != '\n')
 | 
			
		||||
		ret = -EPROTO;
 | 
			
		||||
	fclose(f);
 | 
			
		||||
	errno = -ret;
 | 
			
		||||
	return ret;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user