From: Ben Pfaff Date: Wed, 25 Feb 2015 16:46:02 +0000 (-0800) Subject: json: Fix error message for corner case in json_string_unescape(). X-Git-Tag: v2.3.2~6 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=33cd56ae7b1b91eb51787bdbf6cf5326243742e7 json: Fix error message for corner case in json_string_unescape(). The error message should not include bytes already copied from the input string. Found by inspection. Signed-off-by: Ben Pfaff Acked-by: Alex Wang --- diff --git a/lib/json.c b/lib/json.c index 9c819d7ff..696b5d4bb 100644 --- a/lib/json.c +++ b/lib/json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012, 2014 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -830,6 +830,7 @@ json_string_unescape(const char *in, size_t in_len, char **outp) * lexer will never pass in a string that ends in a single * backslash, but json_string_unescape() has other callers that * are not as careful.*/ + ds_clear(&out); ds_put_cstr(&out, "quoted string may not end with backslash"); goto exit; } diff --git a/tests/ovsdb-data.at b/tests/ovsdb-data.at index 51d32e731..f44d6d4f2 100644 --- a/tests/ovsdb-data.at +++ b/tests/ovsdb-data.at @@ -286,6 +286,14 @@ OVSDB_CHECK_NEGATIVE([quotes must be balanced], [parse-atom-strings '[["string"]]' '"asdf'], ["asdf: missing quote at end of quoted string]) +OVSDB_CHECK_NEGATIVE([quoted string must not contain unescaped quote], + [parse-atom-strings '[["string"]]' '"as"df"'], + ["as"df": quoted string may not include unescaped "]) + +OVSDB_CHECK_NEGATIVE([quoted string must not end with backslash], + [parse-atom-strings '[["string"]]' '"asdf\"'], + ["asdf\": quoted string may not end with backslash]) + OVSDB_CHECK_NEGATIVE([uuids must be valid], [parse-atom-strings '[["uuid"]]' '1234-5678'], ["1234-5678" is not a valid UUID])