Skip to content

Commit

Permalink
Fix string validation for configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
fosslinux committed May 12, 2024
1 parent 9ae0bd9 commit c599e53
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions seed/configurator.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,24 @@ int set_val(Entry *entry, char *val) {
} else if (entry->type == TYPE_STRING) {
/* Validation rules. */
char *validation = entry->validation;
char *prev = validation;
char *next;
int found = FALSE;
if (strcmp(validation, "") == 0) {
found = TRUE;
}
while (prev != NULL) {
if (prev[0] == '\0') {
while (validation != NULL) {
if (validation[0] == '\0') {
break;
}
validation = strchr(validation, '|');
if (validation != NULL) {
validation[0] = '\0';
validation += 1;
if (strcmp(prev, val) == 0) {
next = strchr(validation, '|');
if (next == NULL) {
if (strcmp(validation, val) == 0) {
found = TRUE;
}
break;
} else {
if (strncmp(validation, val, next - validation) == 0) {
found = TRUE;
}
}
prev = validation;
validation = next + 1;
}
if (found == FALSE) {
fputs("Invalid input: ", stdout);
Expand Down

0 comments on commit c599e53

Please sign in to comment.