mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse-server: add another check for the return value of snprintf()
				
					
				
			In addition to checking if the resulting string would be too long, also check whether or not snprintf failed.
This commit is contained in:
		
							parent
							
								
									67b422fa18
								
							
						
					
					
						commit
						30e3884a75
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -68,11 +68,15 @@ int get_runtime_dir(char *buf, size_t buflen, const char *dir)
 | 
			
		|||
		if (getpwuid_r(getuid(), &pwd, buffer, sizeof(buffer), &result) == 0)
 | 
			
		||||
			runtime_dir = result ? result->pw_dir : NULL;
 | 
			
		||||
	}
 | 
			
		||||
	size = snprintf(buf, buflen, "%s/%s", runtime_dir, dir) + 1;
 | 
			
		||||
	if (size > (int) buflen) {
 | 
			
		||||
 | 
			
		||||
	size = snprintf(buf, buflen, "%s/%s", runtime_dir, dir);
 | 
			
		||||
	if (size < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
	if ((size_t) size >= buflen) {
 | 
			
		||||
		pw_log_error(NAME": path %s/%s too long", runtime_dir, dir);
 | 
			
		||||
		return -ENAMETOOLONG;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (stat(buf, &stat_buf) < 0) {
 | 
			
		||||
		res = -errno;
 | 
			
		||||
		if (res != -ENOENT) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue