Audit basename(1)
1) be stricter which number of arguments is accepted (1 or 2) 2) basename already returns a pointer to "." is argv[0] is "" 3) No need to check for *p != '/', because basename() only returns a string beginning with '/' which has length 1, so if strlen(p) == 1, the only way for suffix to be "evaluated" is for off to be > 0, being equal to suffix being "", but "" != "/". 4) don't calculate strlen twice for each string. Store it in a ssize_t and check if it's > 0.
This commit is contained in:
		
							
								
								
									
										6
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								README
									
									
									
									
									
								
							| @@ -7,9 +7,9 @@ across UNIX and UNIX-like systems. | ||||
| The following tools are implemented ('*' == finished, '#' == UTF-8 support, | ||||
| '=' == implicit UTF-8 support, '|' == audited): | ||||
|  | ||||
|    UTILITY         POSIX 2008 COMPLIANT         MISSING OPTIONS | ||||
|    -------         --------------------         --------------- | ||||
| =*  basename        yes                          none | ||||
|     UTILITY         POSIX 2008 COMPLIANT         MISSING OPTIONS | ||||
|     -------         --------------------         --------------- | ||||
| =*| basename        yes                          none | ||||
| =*  cal             yes                          none | ||||
| =*  cat             yes                          none | ||||
| =*  chgrp           yes                          none | ||||
|   | ||||
		Reference in New Issue
	
	Block a user