projects
/
profile
/
ivi
/
jansson.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix packing of invalid UTF-8 strings
[profile/ivi/jansson.git]
/
src
/
pack_unpack.c
diff --git
a/src/pack_unpack.c
b/src/pack_unpack.c
index
eb15b17
..
5001764
100644
(file)
--- a/
src/pack_unpack.c
+++ b/
src/pack_unpack.c
@@
-9,6
+9,7
@@
#include <string.h>
#include <jansson.h>
#include "jansson_private.h"
#include <string.h>
#include <jansson.h>
#include "jansson_private.h"
+#include "utf.h"
typedef struct {
const char *start;
typedef struct {
const char *start;
@@
-110,13
+111,18
@@
static json_t *pack_object(scanner_t *s, va_list *ap)
goto error;
}
goto error;
}
+ if(!utf8_check_string(key, -1)) {
+ set_error(s, "<args>", "Invalid UTF-8 in object key");
+ goto error;
+ }
+
next_token(s);
value = pack(s, ap);
if(!value)
goto error;
next_token(s);
value = pack(s, ap);
if(!value)
goto error;
- if(json_object_set_new(object, key, value)) {
+ if(json_object_set_new
_nocheck
(object, key, value)) {
set_error(s, "<internal>", "Unable to add key \"%s\"", key);
goto error;
}
set_error(s, "<internal>", "Unable to add key \"%s\"", key);
goto error;
}
@@
-178,7
+184,11
@@
static json_t *pack(scanner_t *s, va_list *ap)
set_error(s, "<args>", "NULL string argument");
return NULL;
}
set_error(s, "<args>", "NULL string argument");
return NULL;
}
- return json_string(str);
+ if(!utf8_check_string(str, -1)) {
+ set_error(s, "<args>", "Invalid UTF-8 string");
+ return NULL;
+ }
+ return json_string_nocheck(str);
}
case 'n': /* null */
}
case 'n': /* null */