on master help sign in
Update libyaml to 0.1.5
26c86baMichael Snoyman
libyaml/loader.c+12
@@ -286,6 +286,8 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
286 int index;
286 int index;
287 yaml_char_t *tag = first_event->data.scalar.tag;
287 yaml_char_t *tag = first_event->data.scalar.tag;
288
288
289+ if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
290+
289 if (!tag || strcmp((char *)tag, "!") == 0) {
291 if (!tag || strcmp((char *)tag, "!") == 0) {
290 yaml_free(tag);
292 yaml_free(tag);
291 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
293 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
@@ -329,6 +331,8 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
329 int index, item_index;
331 int index, item_index;
330 yaml_char_t *tag = first_event->data.sequence_start.tag;
332 yaml_char_t *tag = first_event->data.sequence_start.tag;
331
333
334+ if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
335+
332 if (!tag || strcmp((char *)tag, "!") == 0) {
336 if (!tag || strcmp((char *)tag, "!") == 0) {
333 yaml_free(tag);
337 yaml_free(tag);
334 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG);
338 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG);
@@ -351,6 +355,9 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
351 if (!yaml_parser_parse(parser, &event)) return 0;
355 if (!yaml_parser_parse(parser, &event)) return 0;
352
356
353 while (event.type != YAML_SEQUENCE_END_EVENT) {
357 while (event.type != YAML_SEQUENCE_END_EVENT) {
358+ if (!STACK_LIMIT(parser,
359+ parser->document->nodes.start[index-1].data.sequence.items,
360+ INT_MAX-1)) return 0;
354 item_index = yaml_parser_load_node(parser, &event);
361 item_index = yaml_parser_load_node(parser, &event);
355 if (!item_index) return 0;
362 if (!item_index) return 0;
356 if (!PUSH(parser,
363 if (!PUSH(parser,
@@ -387,6 +394,8 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
387 yaml_node_pair_t pair;
394 yaml_node_pair_t pair;
388 yaml_char_t *tag = first_event->data.mapping_start.tag;
395 yaml_char_t *tag = first_event->data.mapping_start.tag;
389
396
397+ if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
398+
390 if (!tag || strcmp((char *)tag, "!") == 0) {
399 if (!tag || strcmp((char *)tag, "!") == 0) {
391 yaml_free(tag);
400 yaml_free(tag);
392 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
401 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
@@ -409,6 +418,9 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
409 if (!yaml_parser_parse(parser, &event)) return 0;
418 if (!yaml_parser_parse(parser, &event)) return 0;
410
419
411 while (event.type != YAML_MAPPING_END_EVENT) {
420 while (event.type != YAML_MAPPING_END_EVENT) {
421+ if (!STACK_LIMIT(parser,
422+ parser->document->nodes.start[index-1].data.mapping.pairs,
423+ INT_MAX-1)) return 0;
412 pair.key = yaml_parser_load_node(parser, &event);
424 pair.key = yaml_parser_load_node(parser, &event);
413 if (!pair.key) return 0;
425 if (!pair.key) return 0;
414 if (!yaml_parser_parse(parser, &event)) return 0;
426 if (!yaml_parser_parse(parser, &event)) return 0;
libyaml/reader.c+4
@@ -460,6 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
460
460
461 }
461 }
462
462
463+ if (parser->offset >= PTRDIFF_MAX)
464+ return yaml_parser_set_reader_error(parser, "input is too long",
465+ PTRDIFF_MAX, -1);
466+
463 return 1;
467 return 1;
464}
468}
465
469
libyaml/scanner.c+18−8
@@ -615,11 +615,11 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser);
615 */
615 */
616
616
617static int
617static int
618−yaml_parser_roll_indent(yaml_parser_t *parser, int column,
618+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
619− int number, yaml_token_type_t type, yaml_mark_t mark);
619+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
620
620
621static int
621static int
622−yaml_parser_unroll_indent(yaml_parser_t *parser, int column);
622+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
623
623
624/*
624/*
625 * Token fetchers.
625 * Token fetchers.
@@ -1103,7 +1103,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
1103 */
1103 */
1104
1104
1105 int required = (!parser->flow_level
1105 int required = (!parser->flow_level
1106− && parser->indent == (int)parser->mark.column);
1106+ && parser->indent == (ptrdiff_t)parser->mark.column);
1107
1107
1108 /*
1108 /*
1109 * A simple key is required only when it is the first token in the current
1109 * A simple key is required only when it is the first token in the current
@@ -1176,6 +1176,11 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser)
1176
1176
1177 /* Increase the flow level. */
1177 /* Increase the flow level. */
1178
1178
1179+ if (parser->flow_level == INT_MAX) {
1180+ parser->error = YAML_MEMORY_ERROR;
1181+ return 0;
1182+ }
1183+
1179 parser->flow_level++;
1184 parser->flow_level++;
1180
1185
1181 return 1;
1186 return 1;
@@ -1206,8 +1211,8 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
1206 */
1211 */
1207
1212
1208static int
1213static int
1209−yaml_parser_roll_indent(yaml_parser_t *parser, int column,
1214+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
1210− int number, yaml_token_type_t type, yaml_mark_t mark)
1215+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
1211{
1216{
1212 yaml_token_t token;
1217 yaml_token_t token;
1213
1218
@@ -1226,6 +1231,11 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column,
1226 if (!PUSH(parser, parser->indents, parser->indent))
1231 if (!PUSH(parser, parser->indents, parser->indent))
1227 return 0;
1232 return 0;
1228
1233
1234+ if (column > INT_MAX) {
1235+ parser->error = YAML_MEMORY_ERROR;
1236+ return 0;
1237+ }
1238+
1229 parser->indent = column;
1239 parser->indent = column;
1230
1240
1231 /* Create a token and insert it into the queue. */
1241 /* Create a token and insert it into the queue. */
@@ -1254,7 +1264,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column,
1254
1264
1255
1265
1256static int
1266static int
1257−yaml_parser_unroll_indent(yaml_parser_t *parser, int column)
1267+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
1258{
1268{
1259 yaml_token_t token;
1269 yaml_token_t token;
1260
1270
@@ -2574,7 +2584,7 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
2574
2584
2575 /* Resize the string to include the head. */
2585 /* Resize the string to include the head. */
2576
2586
2577− while (string.end - string.start <= (int)length) {
2587+ while ((size_t)(string.end - string.start) <= length) {
2578 if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
2588 if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
2579 parser->error = YAML_MEMORY_ERROR;
2589 parser->error = YAML_MEMORY_ERROR;
2580 goto error;
2590 goto error;
libyaml/yaml_private.h+19−2
@@ -7,6 +7,17 @@
7
7
8#include <assert.h>
8#include <assert.h>
9#include <limits.h>
9#include <limits.h>
10+#include <stddef.h>
11+
12+#ifndef _MSC_VER
13+#include <stdint.h>
14+#else
15+#ifdef _WIN64
16+#define PTRDIFF_MAX _I64_MAX
17+#else
18+#define PTRDIFF_MAX INT_MAX
19+#endif
20+#endif
10
21
11/*
22/*
12 * Memory management.
23 * Memory management.
@@ -421,6 +432,12 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
421#define STACK_EMPTY(context,stack) \
432#define STACK_EMPTY(context,stack) \
422 ((stack).start == (stack).top)
433 ((stack).start == (stack).top)
423
434
435+#define STACK_LIMIT(context,stack,size) \
436+ ((stack).top - (stack).start < (size) ? \
437+ 1 : \
438+ ((context)->error = YAML_MEMORY_ERROR, \
439+ 0))
440+
424#define PUSH(context,stack,value) \
441#define PUSH(context,stack,value) \
425 (((stack).top != (stack).end \
442 (((stack).top != (stack).end \
426 || yaml_stack_extend((void **)&(stack).start, \
443 || yaml_stack_extend((void **)&(stack).start, \
@@ -638,7 +655,7 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
638 (node).data.mapping.pairs.top = (node_pairs_start), \
655 (node).data.mapping.pairs.top = (node_pairs_start), \
639 (node).data.mapping.style = (node_style))
656 (node).data.mapping.style = (node_style))
640
657
641−#define YAML_VERSION_STRING "0.1.4"
658+#define YAML_VERSION_STRING "0.1.5"
642#define YAML_VERSION_MAJOR 0
659#define YAML_VERSION_MAJOR 0
643#define YAML_VERSION_MINOR 1
660#define YAML_VERSION_MINOR 1
644−#define YAML_VERSION_PATCH 4
661+#define YAML_VERSION_PATCH 5
yaml.cabal+1−1
@@ -1,5 +1,5 @@
1name: yaml
1name: yaml
2−version: 0.8.7.1
2+version: 0.8.7.2
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov
5author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov