diff options
Diffstat (limited to 'crda.c')
-rw-r--r-- | crda.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -6,7 +6,6 @@ #include <errno.h> #include <stdio.h> -#include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> @@ -95,9 +94,19 @@ static int error_handler(struct sockaddr_nl __attribute__((unused)) *nla, exit(err->error); } +/* Avoid stdlib */ +static int is_len_2(const char *alpha2) +{ + if (alpha2[0] == '\0' || (alpha2[1] == '\0')) + return 0; + if (alpha2[2] == '\0') + return 1; + return 0; +} + static int is_valid_regdom(const char *alpha2) { - if (strlen(alpha2) != 2) + if (!is_len_2(alpha2)) return 0; if (!is_alpha2(alpha2) && !is_world_regdom(alpha2)) |