Fix null dereference in basename
On older kernels (<=linux-5.17), argv[0] can be null. Basename would call strrchr with null if argc==0. Fixes issue #680
This commit is contained in:
		
				
					committed by
					
						 Serge Hallyn
						Serge Hallyn
					
				
			
			
				
	
			
			
			
						parent
						
							300d6ef45c
						
					
				
				
					commit
					c089196e15
				
			| @@ -21,6 +21,10 @@ | |||||||
| #include "prototypes.h" | #include "prototypes.h" | ||||||
| /*@observer@*/const char *Basename (const char *str) | /*@observer@*/const char *Basename (const char *str) | ||||||
| { | { | ||||||
|  | 	if (str == NULL) { | ||||||
|  | 		abort (); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	char *cp = strrchr (str, '/'); | 	char *cp = strrchr (str, '/'); | ||||||
|  |  | ||||||
| 	return (NULL != cp) ? cp + 1 : str; | 	return (NULL != cp) ? cp + 1 : str; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user