diff options
Diffstat (limited to '')
| -rw-r--r-- | src/util.c | 4 | ||||
| -rw-r--r-- | src/util.h | 2 |
2 files changed, 4 insertions, 2 deletions
@@ -234,8 +234,8 @@ int xenopen(int status, const char *path, int flags, int mode, ...) { int fd; - if (!strncmp(path, "/dev/fd/", sizeof("/dev/fd/") - 1)) { - if (!toi(path + sizeof("/dev/fd/") - 1, 0, INT_MAX, &fd)) + if (!strncmp(path, "/dev/fd/", STRLEN("/dev/fd/"))) { + if (!toi(path + STRLEN("/dev/fd/"), 0, INT_MAX, &fd)) return fd; } else if (!strcmp(path, "/dev/stdin")) { return STDIN_FILENO; @@ -5,6 +5,8 @@ #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define CLIP(A, B, C) ((B) < (A) ? (A) : (B) > (C) ? (C) : (B)) +#define STRLEN(STR) (sizeof(STR) - 1) +#define INTSTRLEN(TYPE) ((sizeof(TYPE) == 1 ? 3 : (5 * sizeof(TYPE) / 2)) + (TYPE)-1 < 0) #define USAGE(SYNOPSIS)\ static void usage(void)\ |
