diff options
author | Stephan Eisvogel | 2017-08-25 14:59:56 +0200 |
---|---|---|
committer | Stephan Eisvogel | 2017-08-25 14:59:56 +0200 |
commit | 15ce44a3437d23d739ecadb38e00fe77dd20c0fe (patch) | |
tree | 63eff931afaaa5162f6709dd00cbc942ac743355 | |
parent | 0e79dccca1c276fce9a3c4a5853600f250b0cfcf (diff) | |
download | aur-15ce44a3437d23d739ecadb38e00fe77dd20c0fe.tar.gz |
Do not rely on external patches, instead pull them into package
-rw-r--r-- | .SRCINFO | 12 | ||||
-rw-r--r-- | PKGBUILD | 22 | ||||
-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, 503 insertions, 17 deletions
@@ -1,7 +1,7 @@ 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 = 1 + pkgrel = 2 url = http://nsjail.com arch = x86_64 license = Apache @@ -15,11 +15,11 @@ pkgbase = nsjail-git provides = nsjail conflicts = nsjail source = nsjail-git::git+git://github.com/google/nsjail.git#commit=de927275919864c989972db5e8c437582a4e3055 - source = https://github.com/trustm3/external_protobuf-c-text/commit/c37f8708d847319921a3fba7d6863103f6b801e2.patch - source = https://github.com/trustm3/external_protobuf-c-text/commit/620db2f1a5bf9a1468a2f54ef904977133267aa2.patch - source = https://github.com/trustm3/external_protobuf-c-text/commit/ccb50d69f833b4417ba66690a0257a8a64eab6ec.patch - source = https://github.com/trustm3/external_protobuf-c-text/commit/b79ba3f1cd350a9ebc4929fa9d63368b460b8877.patch - source = https://github.com/trustm3/external_protobuf-c-text/commit/6a8727066180615e7767b550b491e4ef4d0db514.patch + 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 sha256sums = SKIP sha256sums = ff97c12f9415cc662fb688111c8bc0e7136ff0fb7651e24eaa80bf10c3d62685 sha256sums = 50cc5cb09e47ddaaf666541e231429311313233a98ead550b1d46ddc0863ef1b @@ -1,7 +1,7 @@ # Maintainer: Stephan Eisvogel <eisvogel at embinet dot de> pkgname=nsjail-git pkgver=r562.de92727 -pkgrel=1 +pkgrel=2 _pkgcommit=#commit=de927275919864c989972db5e8c437582a4e3055 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') @@ -13,11 +13,11 @@ provides=('nsjail') conflicts=('nsjail') source=("${pkgname}::git+git://github.com/google/nsjail.git${_pkgcommit}" - "https://github.com/trustm3/external_protobuf-c-text/commit/c37f8708d847319921a3fba7d6863103f6b801e2.patch" - "https://github.com/trustm3/external_protobuf-c-text/commit/620db2f1a5bf9a1468a2f54ef904977133267aa2.patch" - "https://github.com/trustm3/external_protobuf-c-text/commit/ccb50d69f833b4417ba66690a0257a8a64eab6ec.patch" - "https://github.com/trustm3/external_protobuf-c-text/commit/b79ba3f1cd350a9ebc4929fa9d63368b460b8877.patch" - "https://github.com/trustm3/external_protobuf-c-text/commit/6a8727066180615e7767b550b491e4ef4d0db514.patch") + "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' @@ -50,15 +50,15 @@ prepare() { cd protobuf-c-text # Fix includes (we ignore the additional Android stuff) - ${_patch} "$srcdir/c37f8708d847319921a3fba7d6863103f6b801e2.patch" + ${_patch} "$srcdir/protobuf-c-text-001.patch" # Fix wrong integer en- and decoding in protobuf-c-text library - ${_patch} "$srcdir/620db2f1a5bf9a1468a2f54ef904977133267aa2.patch" + ${_patch} "$srcdir/protobuf-c-text-002.patch" # Added sanity check for size passed to memcpy - ${_patch} "$srcdir/ccb50d69f833b4417ba66690a0257a8a64eab6ec.patch" + ${_patch} "$srcdir/protobuf-c-text-003.patch" # esc_str: escape with octal as unsigned (buffer overflow otherwise) - ${_patch} "$srcdir/b79ba3f1cd350a9ebc4929fa9d63368b460b8877.patch" + ${_patch} "$srcdir/protobuf-c-text-004.patch" # Fixes bad mallocs and memcpys caused by invalid input - ${_patch} "$srcdir/6a8727066180615e7767b550b491e4ef4d0db514.patch" + ${_patch} "$srcdir/protobuf-c-text-005.patch" } build() { diff --git a/protobuf-c-text-001.patch b/protobuf-c-text-001.patch new file mode 100644 index 000000000000..bb679b57a974 --- /dev/null +++ b/protobuf-c-text-001.patch @@ -0,0 +1,83 @@ +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 new file mode 100644 index 000000000000..fbf8bed06cb7 --- /dev/null +++ b/protobuf-c-text-002.patch @@ -0,0 +1,151 @@ +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 new file mode 100644 index 000000000000..bba5182ca130 --- /dev/null +++ b/protobuf-c-text-003.patch @@ -0,0 +1,34 @@ +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 new file mode 100644 index 000000000000..7ee44573c1ab --- /dev/null +++ b/protobuf-c-text-004.patch @@ -0,0 +1,24 @@ +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 new file mode 100644 index 000000000000..b70c3843a93f --- /dev/null +++ b/protobuf-c-text-005.patch @@ -0,0 +1,194 @@ +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; |