diff options
| author | 2021-12-24 02:49:56 +0100 | |
|---|---|---|
| committer | 2021-12-24 02:49:56 +0100 | |
| commit | a22f0f5dd020958c7a61282e067479add99a0a5a (patch) | |
| tree | 7ea42064702a5826def5e3b584516922d168094e /src/jsmn.h | |
| parent | 914480a8771959bc2dc0f5e8e83365c15c05c36d (diff) | |
| download | libplist-a22f0f5dd020958c7a61282e067479add99a0a5a.tar.gz libplist-a22f0f5dd020958c7a61282e067479add99a0a5a.tar.bz2 | |
json: Update parser (jsmn) to verify the length of the input data
This way the string doesn't have to be 0-terminated.
Diffstat (limited to 'src/jsmn.h')
| -rw-r--r-- | src/jsmn.h | 3 |
1 files changed, 2 insertions, 1 deletions
| @@ -72,6 +72,7 @@ typedef struct { | |||
| 72 | */ | 72 | */ |
| 73 | typedef struct { | 73 | typedef struct { |
| 74 | unsigned int pos; /* offset in the JSON string */ | 74 | unsigned int pos; /* offset in the JSON string */ |
| 75 | unsigned int end; /* offset after last character of JSON string */ | ||
| 75 | int toknext; /* next token to allocate */ | 76 | int toknext; /* next token to allocate */ |
| 76 | int toksuper; /* superior token node, e.g parent object or array */ | 77 | int toksuper; /* superior token node, e.g parent object or array */ |
| 77 | } jsmn_parser; | 78 | } jsmn_parser; |
| @@ -85,7 +86,7 @@ void jsmn_init(jsmn_parser *parser); | |||
| 85 | * Run JSON parser. It parses a JSON data string into and array of tokens, each describing | 86 | * Run JSON parser. It parses a JSON data string into and array of tokens, each describing |
| 86 | * a single JSON object. | 87 | * a single JSON object. |
| 87 | */ | 88 | */ |
| 88 | jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, | 89 | jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, unsigned int length, |
| 89 | jsmntok_t *tokens, unsigned int num_tokens); | 90 | jsmntok_t *tokens, unsigned int num_tokens); |
| 90 | 91 | ||
| 91 | #endif /* __JSMN_H_ */ | 92 | #endif /* __JSMN_H_ */ |
