screwloose
MIS
How can I make the code below secure? Thanks. I am not a C programmer.
***************
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define MAXSTRING 100
#define LEN 80
char s[LEN];
char cmd[MAXSTRING];
main(int argc,char **argv) {
setuid(0);
setgid(0);
if(argc != 2) {
printf("Syntax: %s [stop] [start]\n", argv[0]);
exit(1);
}
printf("The Apache Web Server will %s at your request.\n", argv[1]);
sprintf(cmd,"/usr/local/apache2/bin/apachectl %s\n", argv[1]);
system(cmd);
exit(0);
}
***************
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define MAXSTRING 100
#define LEN 80
char s[LEN];
char cmd[MAXSTRING];
main(int argc,char **argv) {
setuid(0);
setgid(0);
if(argc != 2) {
printf("Syntax: %s [stop] [start]\n", argv[0]);
exit(1);
}
printf("The Apache Web Server will %s at your request.\n", argv[1]);
sprintf(cmd,"/usr/local/apache2/bin/apachectl %s\n", argv[1]);
system(cmd);
exit(0);
}