diff options
author | Stephan Eisvogel | 2018-03-13 21:49:58 +0100 |
---|---|---|
committer | Stephan Eisvogel | 2018-03-13 21:49:58 +0100 |
commit | 5bfc6373938201f6a86b6f6d5932a94710f5a6e8 (patch) | |
tree | 5e4c2e0334f21c30849e5a887cc55fb5260ab8a8 | |
parent | 15ce44a3437d23d739ecadb38e00fe77dd20c0fe (diff) | |
download | aur-5bfc6373938201f6a86b6f6d5932a94710f5a6e8.tar.gz |
Update to nsjail git version of Feb 25 2018
-rw-r--r-- | .SRCINFO | 23 | ||||
-rw-r--r-- | PKGBUILD | 60 | ||||
-rw-r--r-- | protobuf-c-text-001.patch | 83 | ||||
-rw-r--r-- | protobuf-c-text-002.patch | 151 | ||||
-rw-r--r-- | protobuf-c-text-003.patch | 34 | ||||
-rw-r--r-- | protobuf-c-text-004.patch | 24 | ||||
-rw-r--r-- | protobuf-c-text-005.patch | 194 |
7 files changed, 14 insertions, 555 deletions
@@ -1,31 +1,18 @@ pkgbase = nsjail-git pkgdesc = A light-weight process isolation tool, making use of Linux namespaces and seccomp-bpf syscall filters (with help of the kafel bpf language) - pkgver = r562.de92727 - pkgrel = 2 + pkgver = r836.e0c13f5 + pkgrel = 1 url = http://nsjail.com arch = x86_64 license = Apache makedepends = git - makedepends = autoconf-archive>2016.03.20 - makedepends = re2c - makedepends = check>=0.9.4 - depends = libcap depends = libnl>=3 - depends = protobuf-c + depends = protobuf provides = nsjail conflicts = nsjail - source = nsjail-git::git+git://github.com/google/nsjail.git#commit=de927275919864c989972db5e8c437582a4e3055 - source = protobuf-c-text-001.patch - source = protobuf-c-text-002.patch - source = protobuf-c-text-003.patch - source = protobuf-c-text-004.patch - source = protobuf-c-text-005.patch + options = !makeflags + source = nsjail-git::git+git://github.com/google/nsjail.git#commit=e0c13f55a87611282a526a5539ebe578541e4fef sha256sums = SKIP - sha256sums = ff97c12f9415cc662fb688111c8bc0e7136ff0fb7651e24eaa80bf10c3d62685 - sha256sums = 50cc5cb09e47ddaaf666541e231429311313233a98ead550b1d46ddc0863ef1b - sha256sums = 78b4e3c5d66b7e26e25c91f62f2a3fc599356bddac8cb174a2d708d5fc2d997a - sha256sums = 970a3b464e63f5b544fb5e41f7aa6cee13161f12f79d002086fc2aab6aa765f5 - sha256sums = d9289f5b146a036dfafaa7b0cc6ecca73ab32b454ef1bef5c512874391174df2 pkgname = nsjail-git @@ -1,29 +1,19 @@ # Maintainer: Stephan Eisvogel <eisvogel at embinet dot de> pkgname=nsjail-git -pkgver=r562.de92727 -pkgrel=2 -_pkgcommit=#commit=de927275919864c989972db5e8c437582a4e3055 +pkgver=r836.e0c13f5 +pkgrel=1 +_pkgcommit=#commit=e0c13f55a87611282a526a5539ebe578541e4fef pkgdesc="A light-weight process isolation tool, making use of Linux namespaces and seccomp-bpf syscall filters (with help of the kafel bpf language)" arch=('x86_64') url="http://nsjail.com" license=('Apache') -makedepends=('git' 'autoconf-archive>2016.03.20' 're2c' 'check>=0.9.4') -depends=('libcap' 'libnl>=3' 'protobuf-c') +makedepends=('git') +options=('!makeflags') +depends=('libnl>=3' 'protobuf') provides=('nsjail') conflicts=('nsjail') - -source=("${pkgname}::git+git://github.com/google/nsjail.git${_pkgcommit}" - "protobuf-c-text-001.patch" - "protobuf-c-text-002.patch" - "protobuf-c-text-003.patch" - "protobuf-c-text-004.patch" - "protobuf-c-text-005.patch") -sha256sums=('SKIP' - 'ff97c12f9415cc662fb688111c8bc0e7136ff0fb7651e24eaa80bf10c3d62685' - '50cc5cb09e47ddaaf666541e231429311313233a98ead550b1d46ddc0863ef1b' - '78b4e3c5d66b7e26e25c91f62f2a3fc599356bddac8cb174a2d708d5fc2d997a' - '970a3b464e63f5b544fb5e41f7aa6cee13161f12f79d002086fc2aab6aa765f5' - 'd9289f5b146a036dfafaa7b0cc6ecca73ab32b454ef1bef5c512874391174df2') +source=("${pkgname}::git+git://github.com/google/nsjail.git${_pkgcommit}") +sha256sums=('SKIP') pkgver() { cd ${pkgname} @@ -31,40 +21,12 @@ pkgver() { } prepare() { - # Populate kafel and protobuf-c-text submodules + # Populate kafel submodule cd "${srcdir}/${pkgname}" git submodule update --init - - # Package maintainer fixes - - # Fix automake breakage - sed -i '/^include am\/aminclude_doxygen.am/c@DX_RULES@' protobuf-c-text/Makefile.am - # Fix wrong variable usage - sed -i 's/\$(GREP) \/libdata\//\$GREP \/libdata\//' protobuf-c-text/configure.ac - # Fix bison warning - sed -i '/if (!ctxt->lexical_error) {/aYYUSE(scanner);' kafel/src/parser.y - - # 3rd party fixes - - _patch="patch -N -t -p1 --no-backup-if-mismatch -i" - cd protobuf-c-text - - # Fix includes (we ignore the additional Android stuff) - ${_patch} "$srcdir/protobuf-c-text-001.patch" - # Fix wrong integer en- and decoding in protobuf-c-text library - ${_patch} "$srcdir/protobuf-c-text-002.patch" - # Added sanity check for size passed to memcpy - ${_patch} "$srcdir/protobuf-c-text-003.patch" - # esc_str: escape with octal as unsigned (buffer overflow otherwise) - ${_patch} "$srcdir/protobuf-c-text-004.patch" - # Fixes bad mallocs and memcpys caused by invalid input - ${_patch} "$srcdir/protobuf-c-text-005.patch" } build() { - cd "${srcdir}/${pkgname}/protobuf-c-text" - autoreconf -vif - env CFLAGS="${CFLAGS} -fPIC" ./configure --enable-shared=no --disable-doxygen-doc cd "${srcdir}/${pkgname}" make } @@ -80,10 +42,6 @@ package() { install -d "${pkgdir}/usr/share/${pkgname}/examples" install -m644 configs/*.cfg "${pkgdir}/usr/share/${pkgname}/examples" install -m644 LICENSE CONTRIBUTING README.md "${pkgdir}/usr/share/${pkgname}/" - # Configuration directory - install -d "${pkgdir}/etc/nsjail" - echo > "${pkgdir}/etc/nsjail/.placeholder" - echo -e "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo -e "Tip: Your kernel should have CONFIG_USER_NS=y to chroot as a normal user." echo -e " Verify using e.g. this command: zgrep CONFIG_USER_NS /proc/config.gz" diff --git a/protobuf-c-text-001.patch b/protobuf-c-text-001.patch deleted file mode 100644 index bb679b57a974..000000000000 --- a/protobuf-c-text-001.patch +++ /dev/null @@ -1,83 +0,0 @@ -From c37f8708d847319921a3fba7d6863103f6b801e2 Mon Sep 17 00:00:00 2001 -From: Benjamin Weggenmann <benjamin.weggenmann@aisec.fraunhofer.de> -Date: Tue, 27 May 2014 18:29:04 +0200 -Subject: [PATCH] Added Android.mk file for integration into Android build - system and fixed includes. - ---- - Android.mk | 35 +++++++++++++++++++++++++++++++++++ - protobuf-c-text/generate.c | 2 +- - protobuf-c-text/parse.re | 1 - - 3 files changed, 36 insertions(+), 2 deletions(-) - create mode 100644 Android.mk - -diff --git a/Android.mk b/Android.mk -new file mode 100644 -index 0000000..71fb210 ---- /dev/null -+++ b/Android.mk -@@ -0,0 +1,35 @@ -+LOCAL_PATH:= $(call my-dir) -+ -+include $(CLEAR_VARS) -+ -+LOCAL_MODULE := libprotobuf-c-text -+LOCAL_MODULE_TAGS := optional -+#LOCAL_PRELINK_MODULE := false -+LOCAL_MODULE_CLASS := STATIC_LIBRARIES -+ -+LOCAL_STATIC_LIBRARIES := libc \ -+ libprotobuf-c -+ -+LOCAL_SRC_FILES := protobuf-c-text/generate.c -+#$(call all-c-files-under,protobuf-c-text) -+ -+LOCAL_C_INCLUDES += $(LOCAL_PATH)/protobuf-c-text -+ -+LOCAL_C_FLAGS := -std=c99 -pedantic -Wall -DHAVE_PROTOBUF_C_MESSAGE_CHECK -+ -+# Use this variable when building with NDK out of tree -+#LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH) -+#LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) -+LOCAL_COPY_HEADERS_TO := google/protobuf-c -+LOCAL_COPY_HEADERS := protobuf-c-text/protobuf-c-text.h -+ -+# compile parse.re to parse.c using re2c -+intermediates := $(local-intermediates-dir) -+GEN := $(intermediates)/parse.c -+$(GEN): PRIVATE_CUSTOM_TOOL = re2c -s -o $@ $< -+$(GEN): $(LOCAL_PATH)/protobuf-c-text/parse.re -+ $(transform-generated-source) -+LOCAL_GENERATED_SOURCES += $(GEN) -+ -+include $(BUILD_STATIC_LIBRARY) -+ -diff --git a/protobuf-c-text/generate.c b/protobuf-c-text/generate.c -index b326c6e..94dc3d2 100644 ---- a/protobuf-c-text/generate.c -+++ b/protobuf-c-text/generate.c -@@ -14,11 +14,11 @@ - #include <stdarg.h> - #include <stdio.h> - #include <string.h> -+#include <ctype.h> - #include <stdlib.h> - #include <protobuf-c/protobuf-c.h> - #include "protobuf-c-text.h" - #include "protobuf-c-util.h" --#include "config.h" - - /** A dynamic string struct. - * -diff --git a/protobuf-c-text/parse.re b/protobuf-c-text/parse.re -index 85e17a0..3f223b2 100644 ---- a/protobuf-c-text/parse.re -+++ b/protobuf-c-text/parse.re -@@ -32,7 +32,6 @@ - #include <protobuf-c/protobuf-c.h> - #include "protobuf-c-text.h" - #include "protobuf-c-util.h" --#include "config.h" - - /** \defgroup utility Utility functions - * \ingroup internal diff --git a/protobuf-c-text-002.patch b/protobuf-c-text-002.patch deleted file mode 100644 index fbf8bed06cb7..000000000000 --- a/protobuf-c-text-002.patch +++ /dev/null @@ -1,151 +0,0 @@ -From 620db2f1a5bf9a1468a2f54ef904977133267aa2 Mon Sep 17 00:00:00 2001 -From: Benjamin Weggenmann <benjamin.weggenmann@aisec.fraunhofer.de> -Date: Tue, 18 Nov 2014 16:51:49 +0100 -Subject: [PATCH] Fix wrong integer en- and decoding in protobuf-c-text - library. - -See also https://developers.google.com/protocol-buffers/docs/proto#scalar. - -Use C99 macros from inttypes.h for compatibility with different architectures (32 and 64 bit). - -Change-Id: I1d0f8a80b16cfa7969b8a9ebbfc7d2917500febb ---- - protobuf-c-text/generate.c | 21 +++++++++++---------- - protobuf-c-text/parse.re | 4 ++-- - 2 files changed, 13 insertions(+), 12 deletions(-) - -diff --git a/protobuf-c-text/generate.c b/protobuf-c-text/generate.c -index 94dc3d2..2a02130 100644 ---- a/protobuf-c-text/generate.c -+++ b/protobuf-c-text/generate.c -@@ -15,6 +15,7 @@ - #include <stdio.h> - #include <string.h> - #include <ctype.h> -+#include <inttypes.h> - #include <stdlib.h> - #include <protobuf-c/protobuf-c.h> - #include "protobuf-c-text.h" -@@ -222,76 +223,76 @@ protobuf_c_text_to_string_internal(ReturnString *rs, - quantifier_offset = STRUCT_MEMBER(size_t, m, f[i].quantifier_offset); - /* Field exists and has data, dump it. */ - switch (f[i].type) { -- case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_FIXED32: - if (f[i].label == PROTOBUF_C_LABEL_REPEATED) { - for (j = 0; j < quantifier_offset; j++) { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %u\n", -+ "%*s%s: %" PRIu32 "\n", - level, "", f[i].name, - STRUCT_MEMBER(uint32_t *, m, f[i].offset)[j]); - } - } else { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %u\n", -+ "%*s%s: %" PRIu32 "\n", - level, "", f[i].name, - STRUCT_MEMBER(uint32_t, m, f[i].offset)); - } - break; -+ case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_SINT32: - case PROTOBUF_C_TYPE_SFIXED32: - if (f[i].label == PROTOBUF_C_LABEL_REPEATED) { - for (j = 0; j < quantifier_offset; j++) { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %d\n", -+ "%*s%s: %" PRId32 "\n", - level, "", f[i].name, - STRUCT_MEMBER(int32_t *, m, f[i].offset)[j]); - } - } else { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %d\n", -+ "%*s%s: %" PRId32 "\n", - level, "", f[i].name, - STRUCT_MEMBER(int32_t, m, f[i].offset)); - } - break; -- case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - case PROTOBUF_C_TYPE_FIXED64: - if (f[i].label == PROTOBUF_C_LABEL_REPEATED) { - for (j = 0; j < quantifier_offset; j++) { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %lu\n", -+ "%*s%s: %" PRIu64 "\n", - level, "", f[i].name, - STRUCT_MEMBER(uint64_t *, m, f[i].offset)[j]); - } - } else { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %lu\n", -+ "%*s%s: %" PRIu64 "\n", - level, "", f[i].name, - STRUCT_MEMBER(uint64_t, m, f[i].offset)); - } - break; -+ case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_SINT64: - case PROTOBUF_C_TYPE_SFIXED64: - if (f[i].label == PROTOBUF_C_LABEL_REPEATED) { - for (j = 0; j < quantifier_offset; j++) { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %ld\n", -+ "%*s%s: %" PRId64 "\n", - level, "", f[i].name, - STRUCT_MEMBER(int64_t *, m, f[i].offset)[j]); - } - } else { - rs_append(rs, level + strlen(f[i].name) + 20, - allocator, -- "%*s%s: %ld\n", -+ "%*s%s: %" PRId64 "\n", - level, "", f[i].name, - STRUCT_MEMBER(int64_t, m, f[i].offset)); - } -diff --git a/protobuf-c-text/parse.re b/protobuf-c-text/parse.re -index 3f223b2..d6fc5ad 100644 ---- a/protobuf-c-text/parse.re -+++ b/protobuf-c-text/parse.re -@@ -944,7 +944,6 @@ state_value(State *state, Token *t) - - case TOK_NUMBER: - switch (state->field->type) { -- case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_FIXED32: - val = strtoul(t->number, &end, 10); -@@ -975,6 +974,7 @@ state_value(State *state, Token *t) - } - break; - -+ case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_SINT32: - case PROTOBUF_C_TYPE_SFIXED32: - val = strtol(t->number, &end, 10); -@@ -1005,7 +1005,6 @@ state_value(State *state, Token *t) - } - break; - -- case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - case PROTOBUF_C_TYPE_FIXED64: - val = strtoull(t->number, &end, 10); -@@ -1036,6 +1035,7 @@ state_value(State *state, Token *t) - } - break; - -+ case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_SINT64: - case PROTOBUF_C_TYPE_SFIXED64: - val = strtoll(t->number, &end, 10); diff --git a/protobuf-c-text-003.patch b/protobuf-c-text-003.patch deleted file mode 100644 index bba5182ca130..000000000000 --- a/protobuf-c-text-003.patch +++ /dev/null @@ -1,34 +0,0 @@ -From ccb50d69f833b4417ba66690a0257a8a64eab6ec Mon Sep 17 00:00:00 2001 -From: Constanze Hausner <constanze.hausner@aisec.fraunhofer.de> -Date: Fri, 5 Dec 2014 14:22:42 +0100 -Subject: [PATCH] Added sanity check for size passed to memcpy - -Change-Id: I8c9bf96fd20c13afeaec3d2a1211cb2928991913 ---- - protobuf-c-text/parse.re | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/protobuf-c-text/parse.re b/protobuf-c-text/parse.re -index d6fc5ad..60ee50d 100644 ---- a/protobuf-c-text/parse.re -+++ b/protobuf-c-text/parse.re -@@ -420,6 +420,9 @@ token_start: - if (!t.number) { - RETURN(TOK_MALLOC_ERR); - } -+ if ((scanner->cursor - scanner->token) < 0) { -+ RETURN(TOK_MALLOC_ERR); -+ } - memcpy(t.number, scanner->token, - scanner->cursor - scanner->token); - t.number[scanner->cursor - scanner->token] = '\0'; -@@ -432,6 +435,9 @@ token_start: - if (!t.bareword) { - RETURN(TOK_MALLOC_ERR); - } -+ if ((scanner->cursor - scanner->token) < 0) { -+ RETURN(TOK_MALLOC_ERR); -+ } - memcpy(t.bareword, scanner->token, - scanner->cursor - scanner->token); - t.bareword[scanner->cursor - scanner->token] = '\0'; diff --git a/protobuf-c-text-004.patch b/protobuf-c-text-004.patch deleted file mode 100644 index 7ee44573c1ab..000000000000 --- a/protobuf-c-text-004.patch +++ /dev/null @@ -1,24 +0,0 @@ -From b79ba3f1cd350a9ebc4929fa9d63368b460b8877 Mon Sep 17 00:00:00 2001 -From: Serge Ziryukin <ftrvxmtrx@gmail.com> -Date: Sun, 13 Sep 2015 00:39:32 +0200 -Subject: [PATCH] esc_str: escape with octal as unsigned (buffer overflow - otherwise) - -Signed-off-by: Serge Ziryukin <ftrvxmtrx@gmail.com> ---- - protobuf-c-text/generate.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/protobuf-c-text/generate.c b/protobuf-c-text/generate.c -index b326c6e..6a2b414 100644 ---- a/protobuf-c-text/generate.c -+++ b/protobuf-c-text/generate.c -@@ -148,7 +148,7 @@ esc_str(char *src, int len, ProtobufCAllocator *allocator) - /* Escape with octal if !isprint. */ - default: - if (!isprint(src[i])) { -- dst_len += sprintf(dst + dst_len, "\\%03o", src[i]); -+ dst_len += sprintf(dst + dst_len, "\\%03o", (unsigned char)src[i]); - } else { - dst[dst_len++] = src[i]; - } diff --git a/protobuf-c-text-005.patch b/protobuf-c-text-005.patch deleted file mode 100644 index b70c3843a93f..000000000000 --- a/protobuf-c-text-005.patch +++ /dev/null @@ -1,194 +0,0 @@ -From 6a8727066180615e7767b550b491e4ef4d0db514 Mon Sep 17 00:00:00 2001 -From: Benjamin Weggenmann <benjamin.weggenmann@aisec.fraunhofer.de> -Date: Mon, 20 Apr 2015 19:21:57 +0200 -Subject: [PATCH] Handle invalid input and single-line comments in parser. - -Fixes bad mallocs and memcpys caused by invalid input. ---- - protobuf-c-text/parse.re | 91 +++++++++++++++++++++++++++++++----------------- - 1 file changed, 59 insertions(+), 32 deletions(-) - -diff --git a/protobuf-c-text/parse.re b/protobuf-c-text/parse.re -index fdae98c..c3859f2 100644 ---- a/protobuf-c-text/parse.re -+++ b/protobuf-c-text/parse.re -@@ -97,6 +97,8 @@ typedef enum { - TOK_QUOTED, /**< A quoted string. */ - TOK_NUMBER, /**< A number. */ - TOK_BOOLEAN, /**< The unquoted form of "true" and "false". */ -+ TOK_COMMENT, /**< A single-line comment. */ -+ TOK_INVALID, /**< An invalid character. */ - TOK_MALLOC_ERR /**< A memory allocation error occurred. */ - } TokenId; - -@@ -129,23 +131,27 @@ token2txt(Token *t) - { - switch (t->id) { - case TOK_EOF: -- return "[EOF]"; break; -+ return "[EOF]"; - case TOK_BAREWORD: -- return t->bareword; break; -+ return t->bareword; - case TOK_OBRACE: -- return "{"; break; -+ return "{"; - case TOK_CBRACE: -- return "}"; break; -+ return "}"; - case TOK_COLON: -- return ":"; break; -+ return ":"; - case TOK_QUOTED: -- return "[string]"; break; -+ return "[string]"; - case TOK_NUMBER: -- return t->number; break; -+ return t->number; - case TOK_BOOLEAN: -- return t->boolean? "true": "false"; break; -+ return t->boolean? "true": "false"; -+ case TOK_COMMENT: -+ return "[COMMENT]"; -+ case TOK_INVALID: -+ return "[INVALID]"; - default: -- return "[UNKNOWN]"; break; -+ return "[UNKNOWN]"; - } - } - -@@ -217,10 +223,8 @@ static void - scanner_init_string(Scanner *scanner, char *buf) - { - memset(scanner, 0, sizeof(Scanner)); -- scanner->buffer = buf; -- scanner->marker = buf; -- scanner->cursor = buf; -- scanner->limit = &buf[strlen(buf)]; -+ scanner->cursor = scanner->marker = scanner->buffer = (unsigned char *)buf; -+ scanner->limit = (unsigned char *)&buf[strlen(buf)]; - scanner->line = 1; - } - -@@ -237,6 +241,17 @@ scanner_free(Scanner *scanner, ProtobufCAllocator *allocator) - scanner->buffer = NULL; - } - -+/** Check if the given character is octal. -+ * -+ * \param[in] c Character to check. -+ * \return true if c is between '0' and '7', false otherwise. -+ */ -+static int -+is_octal(unsigned char c) -+{ -+ return (c >= '0' && c <= '7'); -+} -+ - /** Unescape string. - * - * Remove escape sequences from a string and replace them with the -@@ -256,6 +271,8 @@ unesc_str(unsigned char *src, int len, ProtobufCAllocator *allocator) - unsigned char *dst; - int i = 0, dst_len = 0; - unsigned char oct[4]; -+ unsigned char c; -+ unsigned int octal; - - dst_pbbd = PBC_ALLOC(sizeof(ProtobufCBinaryData)); - dst = PBC_ALLOC(len + 1); -@@ -273,19 +290,21 @@ unesc_str(unsigned char *src, int len, ProtobufCAllocator *allocator) - /* Fell off the end of the string after \. */ - goto unesc_str_error; - } -- switch (src[i]) { -- case '0': -- if (i + 2 < len -- && (src[i+1] >= '0' && src[i+1] <= '7') -- && (src[i+2] >= '0' && src[i+2] <= '7')) { -- memcpy(oct, src + i, 3); -- dst[dst_len++] = (unsigned char)strtoul(oct, NULL, 8); -- i += 2; /* Gets incremented again down below. */ -- } else { -- /* Decoding a \0 failed or was cut off.. */ -- goto unesc_str_error; -+ if (is_octal(src[i])) { -+ octal = src[i]-'0'; -+ i++; -+ if (i<len && is_octal(src[i])) { -+ octal = octal*8 + src[i]-'0'; -+ i++; -+ if (i<len && is_octal(src[i])) { -+ octal = octal*8 + src[i]-'0'; -+ i++; - } -- break; -+ } -+ dst[dst_len++] = (unsigned char)octal; -+ continue; -+ } -+ switch (src[i]) { - case '\'': - dst[dst_len++] = '\''; - break; -@@ -341,7 +360,7 @@ unesc_str_error: - static int - fill(Scanner *scanner, ProtobufCAllocator *allocator) - { -- char *buf; -+ unsigned char *buf; - int len, oldlen, nmemb; - - if (scanner->token > scanner->limit) { -@@ -414,6 +433,7 @@ token_start: - NL = "\n"; - QS = ["] (EQ|[^"])* ["]; - WS = [ \t]; -+ CM = [#] [^\n]*; - - I | F { - t.number = PBC_ALLOC((scanner->cursor - scanner->token) + 1); -@@ -452,6 +472,8 @@ token_start: - WS { goto token_start; } - NL { scanner->line++; goto token_start; } - "\000" { RETURN(TOK_EOF); } -+ CM { RETURN(TOK_COMMENT); } -+ [^] { RETURN(TOK_INVALID); } - */ - } - -@@ -1200,12 +1222,19 @@ protobuf_c_text_parse(const ProtobufCMessageDescriptor *descriptor, - - while (state_id != STATE_DONE) { - token = scan(scanner, allocator); -- if (token.id == TOK_MALLOC_ERR) { -- token_free(&token, allocator); -- state_error(&state, &token, "String unescape or malloc failure."); -+ switch (token.id) { -+ case TOK_COMMENT: -+ break; -+ case TOK_INVALID: -+ state_id = state_error(&state, &token, "Invalid character in input."); -+ break; -+ case TOK_MALLOC_ERR: -+ state_id = state_error(&state, &token, "String unescaped or malloc failure."); -+ break; -+ default: -+ state_id = states[state_id](&state, &token); - break; - } -- state_id = states[state_id](&state, &token); - token_free(&token, allocator); - } - -@@ -1217,9 +1246,7 @@ protobuf_c_text_parse(const ProtobufCMessageDescriptor *descriptor, - } - } else { - msg = state.msgs[0]; --#ifdef HAVE_PROTOBUF_C_MESSAGE_CHECK - result->complete = protobuf_c_message_check(msg); --#endif - } - state_free(&state); - return msg; |