summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nxt_string.c')
-rw-r--r--src/nxt_string.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nxt_string.c b/src/nxt_string.c
index 1ca595a1..ed4ff955 100644
--- a/src/nxt_string.c
+++ b/src/nxt_string.c
@@ -1,11 +1,19 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Alejandro Colomar <alx@kernel.org>
* Copyright (C) NGINX, Inc.
*/
#include <nxt_main.h>
+#include <errno.h>
+#include <stdlib.h>
+
+
+static inline unsigned long nxt_strtoul_noneg(const char *nptr,
+ char **restrict endptr, int base);
+
nxt_str_t *
nxt_str_alloc(nxt_mp_t *mp, size_t length)
@@ -842,3 +850,14 @@ nxt_base64_decode(u_char *dst, u_char *src, size_t length)
return (p - dst);
}
+
+
+static inline unsigned long
+nxt_strtoul_noneg(const char *nptr, char **restrict endptr, int base)
+{
+ if (strtol(nptr, endptr, base) < 0) {
+ errno = ERANGE;
+ return 0;
+ }
+ return strtoul(nptr, endptr, base);
+}