mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: pod: parser: add null terminator
If the supplied buffer has smaller (or equal) size than the length of the string, then `strncpy()` will not place a null terminator in the buffer. Fix that by always setting the last byte of the buffer to zero.
This commit is contained in:
		
							parent
							
								
									b04b52ecf8
								
							
						
					
					
						commit
						871ba61228
					
				
					 1 changed files with 1 additions and 0 deletions
				
			
		| 
						 | 
					@ -364,6 +364,7 @@ do {											\
 | 
				
			||||||
		char *dest = va_arg(args, char*);					\
 | 
							char *dest = va_arg(args, char*);					\
 | 
				
			||||||
		uint32_t maxlen = va_arg(args, uint32_t);				\
 | 
							uint32_t maxlen = va_arg(args, uint32_t);				\
 | 
				
			||||||
		strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1);	\
 | 
							strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1);	\
 | 
				
			||||||
 | 
							dest[maxlen-1] = '\0';							\
 | 
				
			||||||
		break;									\
 | 
							break;									\
 | 
				
			||||||
	}										\
 | 
						}										\
 | 
				
			||||||
	case 'y':									\
 | 
						case 'y':									\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue