strcmp(1): implements use of pledge(2)
This commit is contained in:
		
							parent
							
								
									d6d9c2088e
								
							
						
					
					
						commit
						baa75a2619
					
				
							
								
								
									
										22
									
								
								src/strcmp.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/strcmp.c
									
									
									
									
									
								
							@ -16,20 +16,28 @@
 | 
				
			|||||||
 * You should have received a copy of the GNU Affero General Public License
 | 
					 * You should have received a copy of the GNU Affero General Public License
 | 
				
			||||||
 * along with this program. If not, see https://www.gnu.org/licenses/.
 | 
					 * along with this program. If not, see https://www.gnu.org/licenses/.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#include <stdio.h> /* fprintf(3), stderr */
 | 
					#include <stdio.h> /* fprintf(3), perror(3), stderr */
 | 
				
			||||||
#include <sysexits.h> /* EX_OK, EX_USAGE */
 | 
					#include <sysexits.h> /* EX_OK, EX_OSERR, EX_USAGE */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __OpenBSD__
 | 
				
			||||||
 | 
					#	include <unistd.h> /* pledge(2) */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *program_name = "strcmp";
 | 
					char *program_name = "strcmp";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[]) {
 | 
					int main(int argc, char *argv[]) {
 | 
				
			||||||
 | 
						program_name = argv[0] == NULL ? program_name : argv[0];
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __OpenBSD__
 | 
				
			||||||
 | 
						if (pledge("stdio", NULL) != -1) {
 | 
				
			||||||
 | 
							perror(program_name);
 | 
				
			||||||
 | 
							return EX_OSERR;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (argc < 3) {
 | 
						if (argc < 3) {
 | 
				
			||||||
		(void)fprintf(
 | 
							(void)fprintf(stderr, "Usage: %s string string...\n", program_name);
 | 
				
			||||||
			stderr,
 | 
					 | 
				
			||||||
			"Usage: %s string string...\n",
 | 
					 | 
				
			||||||
			argv[0] == NULL ? program_name : argv[0]
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return EX_USAGE;
 | 
							return EX_USAGE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user