Stricter checks for netname and node names.
- Node names should not be empty. - Net names should not contain slashes or start with a dot, because they are used in pathnames.
This commit is contained in:
parent
61006ced88
commit
6396f42d74
3 changed files with 18 additions and 2 deletions
|
@ -56,6 +56,9 @@ static char (*request_name[]) = {
|
||||||
static splay_tree_t *past_request_tree;
|
static splay_tree_t *past_request_tree;
|
||||||
|
|
||||||
bool check_id(const char *id) {
|
bool check_id(const char *id) {
|
||||||
|
if(!id || !*id)
|
||||||
|
return false;
|
||||||
|
|
||||||
for(; *id; id++)
|
for(; *id; id++)
|
||||||
if(!isalnum(*id) && *id != '_')
|
if(!isalnum(*id) && *id != '_')
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -194,11 +194,16 @@ static bool parse_options(int argc, char **argv) {
|
||||||
|
|
||||||
/* netname "." is special: a "top-level name" */
|
/* netname "." is special: a "top-level name" */
|
||||||
|
|
||||||
if(netname && !strcmp(netname, ".")) {
|
if(netname && (!*netname || !strcmp(netname, "."))) {
|
||||||
free(netname);
|
free(netname);
|
||||||
netname = NULL;
|
netname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(netname && (strpbrk(netname, "\\/") || *netname == '.')) {
|
||||||
|
fprintf(stderr, "Invalid character in netname!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1344,6 +1349,9 @@ static int cmd_config(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_id(const char *name) {
|
bool check_id(const char *name) {
|
||||||
|
if(!name || !*name)
|
||||||
|
return false;
|
||||||
|
|
||||||
for(int i = 0; i < strlen(name); i++) {
|
for(int i = 0; i < strlen(name); i++) {
|
||||||
if(!isalnum(name[i]) && name[i] != '_')
|
if(!isalnum(name[i]) && name[i] != '_')
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -231,11 +231,16 @@ static bool parse_options(int argc, char **argv) {
|
||||||
|
|
||||||
/* netname "." is special: a "top-level name" */
|
/* netname "." is special: a "top-level name" */
|
||||||
|
|
||||||
if(netname && !strcmp(netname, ".")) {
|
if(netname && (!*netname || !strcmp(netname, "."))) {
|
||||||
free(netname);
|
free(netname);
|
||||||
netname = NULL;
|
netname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(netname && (strpbrk(netname, "\\/") || *netname == '.')) {
|
||||||
|
fprintf(stderr, "Invalid character in netname!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue