- Node names should not be empty.
- Net names should not contain slashes or start with a dot, because they are
used in pathnames.
static splay_tree_t *past_request_tree;
bool check_id(const char *id) {
+ if(!id || !*id)
+ return false;
+
for(; *id; id++)
if(!isalnum(*id) && *id != '_')
return false;
/* netname "." is special: a "top-level name" */
- if(netname && !strcmp(netname, ".")) {
+ if(netname && (!*netname || !strcmp(netname, "."))) {
free(netname);
netname = NULL;
}
+ if(netname && (strpbrk(netname, "\\/") || *netname == '.')) {
+ fprintf(stderr, "Invalid character in netname!\n");
+ return false;
+ }
+
return true;
}
}
bool check_id(const char *name) {
+ if(!name || !*name)
+ return false;
+
for(int i = 0; i < strlen(name); i++) {
if(!isalnum(name[i]) && name[i] != '_')
return false;
/* netname "." is special: a "top-level name" */
- if(netname && !strcmp(netname, ".")) {
+ if(netname && (!*netname || !strcmp(netname, "."))) {
free(netname);
netname = NULL;
}
+ if(netname && (strpbrk(netname, "\\/") || *netname == '.')) {
+ fprintf(stderr, "Invalid character in netname!\n");
+ return false;
+ }
+
return true;
}