Found my big segfault issues, every syntax is caught if incorrect
This commit is contained in:
parent
a0712ae1e8
commit
2961b16d15
113
src/functions.c
113
src/functions.c
@ -84,11 +84,10 @@ char *process_line(char *line)
|
|||||||
char srch[MAX_NETSRCH_BUF];
|
char srch[MAX_NETSRCH_BUF];
|
||||||
char port[7]; // Should never be more than 6 characters
|
char port[7]; // Should never be more than 6 characters
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:netlisten syntax error, missing quote?");
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:netlisten syntax error, missing quote?");
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
if(strlen(parse_vars(tok_srch)) < 7)
|
if(strlen(parse_vars(tok_srch)) < 7)
|
||||||
@ -102,17 +101,29 @@ char *process_line(char *line)
|
|||||||
|
|
||||||
/* strtok to the content that will be written to file */
|
/* strtok to the content that will be written to file */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
|
if(tok_srch == NULL)
|
||||||
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:netconnect syntax error on data entry (are you quoted?)");
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0) {
|
||||||
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(srch, parse_vars(tok_srch));
|
strcpy(srch, parse_vars(tok_srch));
|
||||||
|
|
||||||
/* strtok to the socket response */
|
/* strtok to the socket response */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
|
if(tok_srch == NULL)
|
||||||
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
|
if(tok_srch == NULL)
|
||||||
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0) {
|
||||||
syn_error("ss:error:netconnect syntax error on data entry (are you quoted?)");
|
syn_error("ss:error:netconnect syntax error on data entry (are you quoted?)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,9 +139,11 @@ char *process_line(char *line)
|
|||||||
{
|
{
|
||||||
char port[7]; // Should never be more than 6 characters
|
char port[7]; // Should never be more than 6 characters
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(tok_srch == NULL)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
syn_error("ss:error:nethttp syntax error, missing quote?");
|
||||||
syn_error("ss:error:sleep syntax error, need trailing integer for operation");
|
|
||||||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
|
syn_error("ss:error:netlisten syntax error, missing quote?");
|
||||||
|
|
||||||
if(strlen(parse_vars(tok_srch)) < 7)
|
if(strlen(parse_vars(tok_srch)) < 7)
|
||||||
{
|
{
|
||||||
@ -143,10 +156,12 @@ char *process_line(char *line)
|
|||||||
|
|
||||||
/* strtok to the content that will be written to file */
|
/* strtok to the content that will be written to file */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
|
if(tok_srch == NULL)
|
||||||
|
syn_error("ss:error:nethttp syntax error, missing quote?");
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
syn_error("ss:error:nethttp syntax error on data entry (are you quoted?)");
|
syn_error("ss:error:nethttp syntax error on data entry (are you quoted?)");
|
||||||
}
|
|
||||||
|
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(strtok(NULL, "\"") == NULL)
|
||||||
syn_error("ss:error:nethttp syntax error, missing end quote");
|
syn_error("ss:error:nethttp syntax error, missing end quote");
|
||||||
@ -171,24 +186,23 @@ char *process_line(char *line)
|
|||||||
char port[7];
|
char port[7];
|
||||||
/* strtok to filename of function */
|
/* strtok to filename of function */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:netconnect syntax error, missing quote?");
|
syn_error("ss:error:nettoss syntax error, missing quote?");
|
||||||
|
|
||||||
/* Check to see if syntax is correct */
|
/* Check to see if syntax is correct */
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
syn_error("ss:error:nettoss syntax error, missing quote?");
|
||||||
syn_error("ss:error:netconnect syntax error, missing quote?");
|
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
strcpy(address, parse_vars(tok_srch));
|
strcpy(address, parse_vars(tok_srch));
|
||||||
|
|
||||||
/* strtok to the content that will be written to file */
|
/* strtok to the content that will be written to file */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
|
if(tok_srch == NULL)
|
||||||
|
syn_error("ss:error:nettoss syntax error, missing quote?");
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
|
syn_error("ss:error:nettoss syntax error on data entry (are you quoted?)");
|
||||||
syn_error("ss:error:netconnect syntax error on data entry (are you quoted?)");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen(parse_vars(tok_srch)) > 6)
|
if(strlen(parse_vars(tok_srch)) > 6)
|
||||||
syn_error("ss:error:nettoss port too long");
|
syn_error("ss:error:nettoss port too long");
|
||||||
@ -196,14 +210,18 @@ char *process_line(char *line)
|
|||||||
strcpy(port, parse_vars(tok_srch));
|
strcpy(port, parse_vars(tok_srch));
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
|
if(tok_srch == NULL)
|
||||||
|
syn_error("ss:error:nettoss syntax error, missing quote?");
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(tok_srch == NULL)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL) {
|
syn_error("ss:error:nettoss syntax error, missing quote?");
|
||||||
syn_error("ss:error:netconnect syntax error on data entry (are you quoted?)");
|
|
||||||
}
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
|
syn_error("ss:error:nettoss syntax error, missing quote?");
|
||||||
|
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(strtok(NULL, "\"") == NULL)
|
||||||
syn_error("ss:error:netconnect syntax error, missing end quote");
|
syn_error("ss:error:nettoss syntax error, missing end quote");
|
||||||
|
|
||||||
strcpy(data, parse_vars(tok_srch));
|
strcpy(data, parse_vars(tok_srch));
|
||||||
|
|
||||||
@ -216,11 +234,10 @@ char *process_line(char *line)
|
|||||||
{
|
{
|
||||||
char *var_conv;
|
char *var_conv;
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:encode syntax error, requires data in quotes");
|
syn_error("ss:error:encode syntax error, requires data in quotes");
|
||||||
|
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:encode syntax error, requires data in quotes");
|
syn_error("ss:error:encode syntax error, requires data in quotes");
|
||||||
|
|
||||||
var_conv = parse_vars(tok_srch);
|
var_conv = parse_vars(tok_srch);
|
||||||
@ -237,11 +254,10 @@ char *process_line(char *line)
|
|||||||
{
|
{
|
||||||
char *var_conv;
|
char *var_conv;
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:decode syntax error, requires data in quotes");
|
syn_error("ss:error:decode syntax error, requires data in quotes");
|
||||||
|
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:decode syntax error, requires data in quotes");
|
syn_error("ss:error:decode syntax error, requires data in quotes");
|
||||||
|
|
||||||
var_conv = parse_vars(tok_srch);
|
var_conv = parse_vars(tok_srch);
|
||||||
@ -259,11 +275,10 @@ char *process_line(char *line)
|
|||||||
char *file_line, *catfile, *file_md5_val;
|
char *file_line, *catfile, *file_md5_val;
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:md5 syntax error, requires a file argument in quotes");
|
syn_error("ss:error:md5 syntax error, requires a file argument in quotes");
|
||||||
|
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:md5 syntax error, requires a file argument in quotes");
|
syn_error("ss:error:md5 syntax error, requires a file argument in quotes");
|
||||||
|
|
||||||
file_line = parse_vars(tok_srch);
|
file_line = parse_vars(tok_srch);
|
||||||
@ -288,13 +303,15 @@ char *process_line(char *line)
|
|||||||
char *cmd_line;
|
char *cmd_line;
|
||||||
int return_val;
|
int return_val;
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:exec syntax error, requires a file argument in quotes");
|
syn_error("ss:error:exec syntax error, requires a file argument in quotes");
|
||||||
|
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:exec syntax error, requires argument in quotes");
|
syn_error("ss:error:exec syntax error, requires argument in quotes");
|
||||||
|
|
||||||
|
if(strtok(NULL, "\"") == NULL)
|
||||||
|
syn_error("ss:error:exec syntax error, missing end quote");
|
||||||
|
|
||||||
cmd_line = parse_vars(tok_srch);
|
cmd_line = parse_vars(tok_srch);
|
||||||
return_val = system(cmd_line);
|
return_val = system(cmd_line);
|
||||||
if(return_val != 0)
|
if(return_val != 0)
|
||||||
@ -312,12 +329,11 @@ char *process_line(char *line)
|
|||||||
FILE* write_file = NULL;
|
FILE* write_file = NULL;
|
||||||
/* strtok to filename of function */
|
/* strtok to filename of function */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:write syntax error, requires a file argument in quotes");
|
syn_error("ss:error:write syntax error, requires a file argument in quotes");
|
||||||
|
|
||||||
/* Check to see if syntax is correct */
|
/* Check to see if syntax is correct */
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:write syntax error, requires filename followed by data; both in quotes");
|
syn_error("ss:error:write syntax error, requires filename followed by data; both in quotes");
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
@ -357,13 +373,15 @@ char *process_line(char *line)
|
|||||||
|
|
||||||
/* strtok to filename of function */
|
/* strtok to filename of function */
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strtok(NULL, "\"") == NULL)
|
if(tok_srch == NULL)
|
||||||
syn_error("ss:error:read syntax error, requires a file argument in quotes");
|
syn_error("ss:error:read syntax error, requires a file argument in quotes");
|
||||||
|
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
|
||||||
syn_error("ss:error:read syntax error, missing filename / in quotes");
|
syn_error("ss:error:read syntax error, missing filename / in quotes");
|
||||||
|
|
||||||
|
if(strtok(NULL, "\"") == NULL)
|
||||||
|
syn_error("ss:error:read syntax error, missing end quote");
|
||||||
|
|
||||||
/* Pull any variables out of the file name
|
/* Pull any variables out of the file name
|
||||||
that may be, and BAM, variable fill! */
|
that may be, and BAM, variable fill! */
|
||||||
filename = parse_vars(tok_srch);
|
filename = parse_vars(tok_srch);
|
||||||
@ -409,10 +427,15 @@ char *process_line(char *line)
|
|||||||
else if(strncmp("delete", tok_srch, 6) == 0) {
|
else if(strncmp("delete", tok_srch, 6) == 0) {
|
||||||
char *del_filename;
|
char *del_filename;
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(strcmp(tok_srch, "\n") == 0 ||
|
if(tok_srch == NULL)
|
||||||
strcmp(tok_srch, " \n") == 0 || tok_srch == NULL)
|
syn_error("ss:error:delete syntax error, missing end quote");
|
||||||
|
|
||||||
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
syn_error("ss:error:delete syntax error, missing file argument");
|
syn_error("ss:error:delete syntax error, missing file argument");
|
||||||
|
|
||||||
|
if(strtok(NULL, "\"") == NULL)
|
||||||
|
syn_error("ss:error:delete syntax error, missing end quote");
|
||||||
|
|
||||||
/* Pull variables out of filename if any */
|
/* Pull variables out of filename if any */
|
||||||
del_filename = parse_vars(tok_srch);
|
del_filename = parse_vars(tok_srch);
|
||||||
if(access(del_filename, F_OK) == 0)
|
if(access(del_filename, F_OK) == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user