mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	zdb: Fix handling of nul termination in symlink targets
The SA attribute containing the symlink target does not include a nul terminator, so when printing the target zdb would sometimes include garbage at the end of the string. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Mark Johnston <markj@FreeBSD.org> Closes #13482
This commit is contained in:
		
							parent
							
								
									96c7c63994
								
							
						
					
					
						commit
						4184b78be1
					
				| @ -3125,13 +3125,18 @@ dump_znode_symlink(sa_handle_t *hdl) | |||||||
| { | { | ||||||
| 	int sa_symlink_size = 0; | 	int sa_symlink_size = 0; | ||||||
| 	char linktarget[MAXPATHLEN]; | 	char linktarget[MAXPATHLEN]; | ||||||
| 	linktarget[0] = '\0'; |  | ||||||
| 	int error; | 	int error; | ||||||
| 
 | 
 | ||||||
| 	error = sa_size(hdl, sa_attr_table[ZPL_SYMLINK], &sa_symlink_size); | 	error = sa_size(hdl, sa_attr_table[ZPL_SYMLINK], &sa_symlink_size); | ||||||
| 	if (error || sa_symlink_size == 0) { | 	if (error || sa_symlink_size == 0) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  | 	if (sa_symlink_size >= sizeof (linktarget)) { | ||||||
|  | 		(void) printf("symlink size %d is too large\n", | ||||||
|  | 		    sa_symlink_size); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 	linktarget[sa_symlink_size] = '\0'; | ||||||
| 	if (sa_lookup(hdl, sa_attr_table[ZPL_SYMLINK], | 	if (sa_lookup(hdl, sa_attr_table[ZPL_SYMLINK], | ||||||
| 	    &linktarget, sa_symlink_size) == 0) | 	    &linktarget, sa_symlink_size) == 0) | ||||||
| 		(void) printf("\ttarget	%s\n", linktarget); | 		(void) printf("\ttarget	%s\n", linktarget); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Mark Johnston
						Mark Johnston