libyaml.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. diff -uw ruby-2.1.0/ext/psych/yaml/api.c ruby-2.1.2/ext/psych/yaml/api.c
  2. --- ruby-2.1.0/ext/psych/yaml/api.c 2012-11-28 05:35:40.000000000 +0100
  3. +++ ruby-2.1.2/ext/psych/yaml/api.c 2014-02-24 05:24:15.000000000 +0100
  4. @@ -395,7 +395,7 @@
  5. }
  6. QUEUE_DEL(emitter, emitter->events);
  7. STACK_DEL(emitter, emitter->indents);
  8. - while (!STACK_EMPTY(empty, emitter->tag_directives)) {
  9. + while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
  10. yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
  11. yaml_free(tag_directive.handle);
  12. yaml_free(tag_directive.prefix);
  13. @@ -822,6 +822,7 @@
  14. yaml_char_t *anchor_copy = NULL;
  15. yaml_char_t *tag_copy = NULL;
  16. yaml_char_t *value_copy = NULL;
  17. + size_t value_length;
  18. assert(event); /* Non-NULL event object is expected. */
  19. assert(value); /* Non-NULL anchor is expected. */
  20. @@ -839,16 +840,19 @@
  21. }
  22. if (length < 0) {
  23. - length = strlen((char *)value);
  24. + value_length = strlen((char *)value);
  25. + }
  26. + else {
  27. + value_length = (size_t)length;
  28. }
  29. - if (!yaml_check_utf8(value, length)) goto error;
  30. - value_copy = yaml_malloc(length+1);
  31. + if (!yaml_check_utf8(value, value_length)) goto error;
  32. + value_copy = yaml_malloc(value_length+1);
  33. if (!value_copy) goto error;
  34. - memcpy(value_copy, value, length);
  35. - value_copy[length] = '\0';
  36. + memcpy(value_copy, value, value_length);
  37. + value_copy[value_length] = '\0';
  38. - SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length,
  39. + SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, value_length,
  40. plain_implicit, quoted_implicit, style, mark, mark);
  41. return 1;
  42. @@ -1202,6 +1206,8 @@
  43. yaml_char_t *tag_copy = NULL;
  44. yaml_char_t *value_copy = NULL;
  45. yaml_node_t node;
  46. + size_t value_length;
  47. + ptrdiff_t ret;
  48. assert(document); /* Non-NULL document object is expected. */
  49. assert(value); /* Non-NULL value is expected. */
  50. @@ -1215,19 +1221,26 @@
  51. if (!tag_copy) goto error;
  52. if (length < 0) {
  53. - length = strlen((char *)value);
  54. + value_length = strlen((char *)value);
  55. + }
  56. + else {
  57. + value_length = (size_t)length;
  58. }
  59. - if (!yaml_check_utf8(value, length)) goto error;
  60. - value_copy = yaml_malloc(length+1);
  61. + if (!yaml_check_utf8(value, value_length)) goto error;
  62. + value_copy = yaml_malloc(value_length+1);
  63. if (!value_copy) goto error;
  64. - memcpy(value_copy, value, length);
  65. - value_copy[length] = '\0';
  66. + memcpy(value_copy, value, value_length);
  67. + value_copy[value_length] = '\0';
  68. - SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark);
  69. + SCALAR_NODE_INIT(node, tag_copy, value_copy, value_length, style, mark, mark);
  70. if (!PUSH(&context, document->nodes, node)) goto error;
  71. - return document->nodes.top - document->nodes.start;
  72. + ret = document->nodes.top - document->nodes.start;
  73. +#if PTRDIFF_MAX > INT_MAX
  74. + if (ret > INT_MAX) goto error;
  75. +#endif
  76. + return (int)ret;
  77. error:
  78. yaml_free(tag_copy);
  79. @@ -1255,6 +1268,7 @@
  80. yaml_node_item_t *top;
  81. } items = { NULL, NULL, NULL };
  82. yaml_node_t node;
  83. + ptrdiff_t ret;
  84. assert(document); /* Non-NULL document object is expected. */
  85. @@ -1272,7 +1286,11 @@
  86. style, mark, mark);
  87. if (!PUSH(&context, document->nodes, node)) goto error;
  88. - return document->nodes.top - document->nodes.start;
  89. + ret = document->nodes.top - document->nodes.start;
  90. +#if PTRDIFF_MAX > INT_MAX
  91. + if (ret > INT_MAX) goto error;
  92. +#endif
  93. + return (int)ret;
  94. error:
  95. STACK_DEL(&context, items);
  96. @@ -1300,6 +1318,7 @@
  97. yaml_node_pair_t *top;
  98. } pairs = { NULL, NULL, NULL };
  99. yaml_node_t node;
  100. + ptrdiff_t ret;
  101. assert(document); /* Non-NULL document object is expected. */
  102. @@ -1317,7 +1336,11 @@
  103. style, mark, mark);
  104. if (!PUSH(&context, document->nodes, node)) goto error;
  105. - return document->nodes.top - document->nodes.start;
  106. + ret = document->nodes.top - document->nodes.start;
  107. +#if PTRDIFF_MAX > INT_MAX
  108. + if (ret > INT_MAX) goto error;
  109. +#endif
  110. + return (int)ret;
  111. error:
  112. STACK_DEL(&context, pairs);
  113. diff -uw ruby-2.1.0/ext/psych/yaml/config.h ruby-2.1.2/ext/psych/yaml/config.h
  114. --- ruby-2.1.0/ext/psych/yaml/config.h 2012-12-01 04:58:39.000000000 +0100
  115. +++ ruby-2.1.2/ext/psych/yaml/config.h 2014-05-04 17:45:33.000000000 +0200
  116. @@ -1,11 +1,10 @@
  117. -
  118. #define PACKAGE_NAME "yaml"
  119. #define PACKAGE_TARNAME "yaml"
  120. -#define PACKAGE_VERSION "0.1.4"
  121. -#define PACKAGE_STRING "yaml 0.1.4"
  122. +#define PACKAGE_VERSION "0.1.6"
  123. +#define PACKAGE_STRING "yaml 0.1.6"
  124. #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml"
  125. #define PACKAGE_URL ""
  126. #define YAML_VERSION_MAJOR 0
  127. #define YAML_VERSION_MINOR 1
  128. -#define YAML_VERSION_PATCH 4
  129. -#define YAML_VERSION_STRING "0.1.4"
  130. +#define YAML_VERSION_PATCH 6
  131. +#define YAML_VERSION_STRING "0.1.6"
  132. diff -uw ruby-2.1.0/ext/psych/yaml/emitter.c ruby-2.1.2/ext/psych/yaml/emitter.c
  133. --- ruby-2.1.0/ext/psych/yaml/emitter.c 2013-12-14 02:19:06.000000000 +0100
  134. +++ ruby-2.1.2/ext/psych/yaml/emitter.c 2014-02-24 05:24:15.000000000 +0100
  135. @@ -53,7 +53,7 @@
  136. #define WRITE_BREAK(emitter,string) \
  137. (FLUSH(emitter) \
  138. && (CHECK(string,'\n') ? \
  139. - (PUT_BREAK(emitter), \
  140. + ((void)PUT_BREAK(emitter), \
  141. string.pointer ++, \
  142. 1) : \
  143. (COPY(emitter->buffer,string), \
  144. @@ -1493,7 +1493,7 @@
  145. int break_space = 0;
  146. int space_break = 0;
  147. - int preceded_by_whitespace = 0;
  148. + int preceeded_by_whitespace = 0;
  149. int followed_by_whitespace = 0;
  150. int previous_space = 0;
  151. int previous_break = 0;
  152. @@ -1524,7 +1524,7 @@
  153. flow_indicators = 1;
  154. }
  155. - preceded_by_whitespace = 1;
  156. + preceeded_by_whitespace = 1;
  157. followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
  158. while (string.pointer != string.end)
  159. @@ -1570,7 +1570,7 @@
  160. }
  161. }
  162. - if (CHECK(string, '#') && preceded_by_whitespace) {
  163. + if (CHECK(string, '#') && preceeded_by_whitespace) {
  164. flow_indicators = 1;
  165. block_indicators = 1;
  166. }
  167. @@ -1619,7 +1619,7 @@
  168. previous_break = 0;
  169. }
  170. - preceded_by_whitespace = IS_BLANKZ(string);
  171. + preceeded_by_whitespace = IS_BLANKZ(string);
  172. MOVE(string);
  173. if (string.pointer != string.end) {
  174. followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
  175. diff -uw ruby-2.1.0/ext/psych/yaml/loader.c ruby-2.1.2/ext/psych/yaml/loader.c
  176. --- ruby-2.1.0/ext/psych/yaml/loader.c 2012-11-28 05:35:40.000000000 +0100
  177. +++ ruby-2.1.2/ext/psych/yaml/loader.c 2014-02-24 05:24:15.000000000 +0100
  178. @@ -283,9 +283,12 @@
  179. yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
  180. {
  181. yaml_node_t node;
  182. + ptrdiff_t node_index;
  183. int index;
  184. yaml_char_t *tag = first_event->data.scalar.tag;
  185. + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
  186. +
  187. if (!tag || strcmp((char *)tag, "!") == 0) {
  188. yaml_free(tag);
  189. tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
  190. @@ -298,7 +301,11 @@
  191. if (!PUSH(parser, parser->document->nodes, node)) goto error;
  192. - index = parser->document->nodes.top - parser->document->nodes.start;
  193. + node_index = parser->document->nodes.top - parser->document->nodes.start;
  194. +#if PTRDIFF_MAX > INT_MAX
  195. + if (node_index > INT_MAX) goto error;
  196. +#endif
  197. + index = (int)node_index;
  198. if (!yaml_parser_register_anchor(parser, index,
  199. first_event->data.scalar.anchor)) return 0;
  200. @@ -327,8 +334,11 @@
  201. yaml_node_item_t *top;
  202. } items = { NULL, NULL, NULL };
  203. int index, item_index;
  204. + ptrdiff_t node_index;
  205. yaml_char_t *tag = first_event->data.sequence_start.tag;
  206. + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
  207. +
  208. if (!tag || strcmp((char *)tag, "!") == 0) {
  209. yaml_free(tag);
  210. tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG);
  211. @@ -343,7 +353,11 @@
  212. if (!PUSH(parser, parser->document->nodes, node)) goto error;
  213. - index = parser->document->nodes.top - parser->document->nodes.start;
  214. + node_index = parser->document->nodes.top - parser->document->nodes.start;
  215. +#if PTRDIFF_MAX > INT_MAX
  216. + if (node_index > INT_MAX) goto error;
  217. +#endif
  218. + index = (int)node_index;
  219. if (!yaml_parser_register_anchor(parser, index,
  220. first_event->data.sequence_start.anchor)) return 0;
  221. @@ -351,6 +365,9 @@
  222. if (!yaml_parser_parse(parser, &event)) return 0;
  223. while (event.type != YAML_SEQUENCE_END_EVENT) {
  224. + if (!STACK_LIMIT(parser,
  225. + parser->document->nodes.start[index-1].data.sequence.items,
  226. + INT_MAX-1)) return 0;
  227. item_index = yaml_parser_load_node(parser, &event);
  228. if (!item_index) return 0;
  229. if (!PUSH(parser,
  230. @@ -384,9 +401,12 @@
  231. yaml_node_pair_t *top;
  232. } pairs = { NULL, NULL, NULL };
  233. int index;
  234. + ptrdiff_t node_index;
  235. yaml_node_pair_t pair;
  236. yaml_char_t *tag = first_event->data.mapping_start.tag;
  237. + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
  238. +
  239. if (!tag || strcmp((char *)tag, "!") == 0) {
  240. yaml_free(tag);
  241. tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
  242. @@ -401,7 +421,11 @@
  243. if (!PUSH(parser, parser->document->nodes, node)) goto error;
  244. - index = parser->document->nodes.top - parser->document->nodes.start;
  245. + node_index = parser->document->nodes.top - parser->document->nodes.start;
  246. +#if PTRDIFF_MAX > INT_MAX
  247. + if (node_index > INT_MAX) goto error;
  248. +#endif
  249. + index = (int)node_index;
  250. if (!yaml_parser_register_anchor(parser, index,
  251. first_event->data.mapping_start.anchor)) return 0;
  252. @@ -409,6 +433,9 @@
  253. if (!yaml_parser_parse(parser, &event)) return 0;
  254. while (event.type != YAML_MAPPING_END_EVENT) {
  255. + if (!STACK_LIMIT(parser,
  256. + parser->document->nodes.start[index-1].data.mapping.pairs,
  257. + INT_MAX-1)) return 0;
  258. pair.key = yaml_parser_load_node(parser, &event);
  259. if (!pair.key) return 0;
  260. if (!yaml_parser_parse(parser, &event)) return 0;
  261. diff -uw ruby-2.1.0/ext/psych/yaml/parser.c ruby-2.1.2/ext/psych/yaml/parser.c
  262. --- ruby-2.1.0/ext/psych/yaml/parser.c 2012-12-05 05:08:17.000000000 +0100
  263. +++ ruby-2.1.2/ext/psych/yaml/parser.c 2014-02-24 05:24:15.000000000 +0100
  264. @@ -759,9 +759,8 @@
  265. else if (token->type == YAML_BLOCK_END_TOKEN)
  266. {
  267. - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
  268. parser->state = POP(parser, parser->states);
  269. - dummy_mark = POP(parser, parser->marks);
  270. + (void)POP(parser, parser->marks);
  271. SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
  272. SKIP_TOKEN(parser);
  273. return 1;
  274. @@ -869,9 +868,8 @@
  275. else if (token->type == YAML_BLOCK_END_TOKEN)
  276. {
  277. - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
  278. parser->state = POP(parser, parser->states);
  279. - dummy_mark = POP(parser, parser->marks);
  280. + (void)POP(parser, parser->marks);
  281. MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
  282. SKIP_TOKEN(parser);
  283. return 1;
  284. @@ -952,7 +950,6 @@
  285. yaml_event_t *event, int first)
  286. {
  287. yaml_token_t *token;
  288. - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
  289. if (first) {
  290. token = PEEK_TOKEN(parser);
  291. @@ -997,7 +994,7 @@
  292. }
  293. parser->state = POP(parser, parser->states);
  294. - dummy_mark = POP(parser, parser->marks);
  295. + (void)POP(parser, parser->marks);
  296. SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
  297. SKIP_TOKEN(parser);
  298. return 1;
  299. @@ -1104,7 +1101,6 @@
  300. yaml_event_t *event, int first)
  301. {
  302. yaml_token_t *token;
  303. - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
  304. if (first) {
  305. token = PEEK_TOKEN(parser);
  306. @@ -1158,7 +1154,7 @@
  307. }
  308. parser->state = POP(parser, parser->states);
  309. - dummy_mark = POP(parser, parser->marks);
  310. + (void)POP(parser, parser->marks);
  311. MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
  312. SKIP_TOKEN(parser);
  313. return 1;
  314. diff -uw ruby-2.1.0/ext/psych/yaml/reader.c ruby-2.1.2/ext/psych/yaml/reader.c
  315. --- ruby-2.1.0/ext/psych/yaml/reader.c 2012-12-05 05:08:17.000000000 +0100
  316. +++ ruby-2.1.2/ext/psych/yaml/reader.c 2014-02-24 05:24:15.000000000 +0100
  317. @@ -460,6 +460,10 @@
  318. }
  319. + if (parser->offset >= PTRDIFF_MAX)
  320. + return yaml_parser_set_reader_error(parser, "input is too long",
  321. + PTRDIFF_MAX, -1);
  322. +
  323. return 1;
  324. }
  325. diff -uw ruby-2.1.0/ext/psych/yaml/scanner.c ruby-2.1.2/ext/psych/yaml/scanner.c
  326. --- ruby-2.1.0/ext/psych/yaml/scanner.c 2013-01-13 08:47:10.000000000 +0100
  327. +++ ruby-2.1.2/ext/psych/yaml/scanner.c 2014-05-04 17:45:33.000000000 +0200
  328. @@ -615,11 +615,11 @@
  329. */
  330. static int
  331. -yaml_parser_roll_indent(yaml_parser_t *parser, int column,
  332. - int number, yaml_token_type_t type, yaml_mark_t mark);
  333. +yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
  334. + ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
  335. static int
  336. -yaml_parser_unroll_indent(yaml_parser_t *parser, int column);
  337. +yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
  338. /*
  339. * Token fetchers.
  340. @@ -1103,7 +1103,7 @@
  341. */
  342. int required = (!parser->flow_level
  343. - && parser->indent == (int)parser->mark.column);
  344. + && parser->indent == (ptrdiff_t)parser->mark.column);
  345. /*
  346. * A simple key is required only when it is the first token in the current
  347. @@ -1176,6 +1176,11 @@
  348. /* Increase the flow level. */
  349. + if (parser->flow_level == INT_MAX) {
  350. + parser->error = YAML_MEMORY_ERROR;
  351. + return 0;
  352. + }
  353. +
  354. parser->flow_level++;
  355. return 1;
  356. @@ -1188,11 +1193,9 @@
  357. static int
  358. yaml_parser_decrease_flow_level(yaml_parser_t *parser)
  359. {
  360. - yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */
  361. -
  362. if (parser->flow_level) {
  363. parser->flow_level --;
  364. - dummy_key = POP(parser, parser->simple_keys);
  365. + (void)POP(parser, parser->simple_keys);
  366. }
  367. return 1;
  368. @@ -1206,8 +1209,8 @@
  369. */
  370. static int
  371. -yaml_parser_roll_indent(yaml_parser_t *parser, int column,
  372. - int number, yaml_token_type_t type, yaml_mark_t mark)
  373. +yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
  374. + ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
  375. {
  376. yaml_token_t token;
  377. @@ -1226,7 +1229,14 @@
  378. if (!PUSH(parser, parser->indents, parser->indent))
  379. return 0;
  380. - parser->indent = column;
  381. +#if PTRDIFF_MAX > INT_MAX
  382. + if (column > INT_MAX) {
  383. + parser->error = YAML_MEMORY_ERROR;
  384. + return 0;
  385. + }
  386. +#endif
  387. +
  388. + parser->indent = (int)column;
  389. /* Create a token and insert it into the queue. */
  390. @@ -1248,13 +1258,13 @@
  391. /*
  392. * Pop indentation levels from the indents stack until the current level
  393. - * becomes less or equal to the column. For each indentation level, append
  394. + * becomes less or equal to the column. For each intendation level, append
  395. * the BLOCK-END token.
  396. */
  397. static int
  398. -yaml_parser_unroll_indent(yaml_parser_t *parser, int column)
  399. +yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
  400. {
  401. yaml_token_t token;
  402. @@ -1263,7 +1273,7 @@
  403. if (parser->flow_level)
  404. return 1;
  405. - /* Loop through the indentation levels in the stack. */
  406. + /* Loop through the intendation levels in the stack. */
  407. while (parser->indent > column)
  408. {
  409. @@ -2574,7 +2584,7 @@
  410. /* Resize the string to include the head. */
  411. - while (string.end - string.start <= (int)length) {
  412. + while ((size_t)(string.end - string.start) <= length) {
  413. if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
  414. parser->error = YAML_MEMORY_ERROR;
  415. goto error;
  416. @@ -2619,6 +2629,9 @@
  417. /* Check if it is a URI-escape sequence. */
  418. if (CHECK(parser->buffer, '%')) {
  419. + if (!STRING_EXTEND(parser, string))
  420. + goto error;
  421. +
  422. if (!yaml_parser_scan_uri_escapes(parser,
  423. directive, start_mark, &string)) goto error;
  424. }
  425. @@ -2769,15 +2782,15 @@
  426. if (IS_DIGIT(parser->buffer))
  427. {
  428. - /* Check that the indentation is greater than 0. */
  429. + /* Check that the intendation is greater than 0. */
  430. if (CHECK(parser->buffer, '0')) {
  431. yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
  432. - start_mark, "found an indentation indicator equal to 0");
  433. + start_mark, "found an intendation indicator equal to 0");
  434. goto error;
  435. }
  436. - /* Get the indentation level and eat the indicator. */
  437. + /* Get the intendation level and eat the indicator. */
  438. increment = AS_DIGIT(parser->buffer);
  439. @@ -2791,7 +2804,7 @@
  440. {
  441. if (CHECK(parser->buffer, '0')) {
  442. yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
  443. - start_mark, "found an indentation indicator equal to 0");
  444. + start_mark, "found an intendation indicator equal to 0");
  445. goto error;
  446. }
  447. @@ -2841,7 +2854,7 @@
  448. end_mark = parser->mark;
  449. - /* Set the indentation level if it was specified. */
  450. + /* Set the intendation level if it was specified. */
  451. if (increment) {
  452. indent = parser->indent >= 0 ? parser->indent+increment : increment;
  453. @@ -2907,7 +2920,7 @@
  454. if (!READ_LINE(parser, leading_break)) goto error;
  455. - /* Eat the following indentation spaces and line breaks. */
  456. + /* Eat the following intendation spaces and line breaks. */
  457. if (!yaml_parser_scan_block_scalar_breaks(parser,
  458. &indent, &trailing_breaks, start_mark, &end_mark)) goto error;
  459. @@ -2942,8 +2955,8 @@
  460. }
  461. /*
  462. - * Scan indentation spaces and line breaks for a block scalar. Determine the
  463. - * indentation level if needed.
  464. + * Scan intendation spaces and line breaks for a block scalar. Determine the
  465. + * intendation level if needed.
  466. */
  467. static int
  468. @@ -2955,11 +2968,11 @@
  469. *end_mark = parser->mark;
  470. - /* Eat the indentation spaces and line breaks. */
  471. + /* Eat the intendation spaces and line breaks. */
  472. while (1)
  473. {
  474. - /* Eat the indentation spaces. */
  475. + /* Eat the intendation spaces. */
  476. if (!CACHE(parser, 1)) return 0;
  477. @@ -2972,12 +2985,12 @@
  478. if ((int)parser->mark.column > max_indent)
  479. max_indent = (int)parser->mark.column;
  480. - /* Check for a tab character messing the indentation. */
  481. + /* Check for a tab character messing the intendation. */
  482. if ((!*indent || (int)parser->mark.column < *indent)
  483. && IS_TAB(parser->buffer)) {
  484. return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
  485. - start_mark, "found a tab character where an indentation space is expected");
  486. + start_mark, "found a tab character where an intendation space is expected");
  487. }
  488. /* Have we found a non-empty line? */
  489. @@ -3498,12 +3511,12 @@
  490. {
  491. if (IS_BLANK(parser->buffer))
  492. {
  493. - /* Check for tab character that abuse indentation. */
  494. + /* Check for tab character that abuse intendation. */
  495. if (leading_blanks && (int)parser->mark.column < indent
  496. && IS_TAB(parser->buffer)) {
  497. yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
  498. - start_mark, "found a tab character that violates indentation");
  499. + start_mark, "found a tab character that violate intendation");
  500. goto error;
  501. }
  502. @@ -3536,7 +3549,7 @@
  503. if (!CACHE(parser, 1)) goto error;
  504. }
  505. - /* Check indentation level. */
  506. + /* Check intendation level. */
  507. if (!parser->flow_level && (int)parser->mark.column < indent)
  508. break;
  509. diff -uw ruby-2.1.0/ext/psych/yaml/yaml_private.h ruby-2.1.2/ext/psych/yaml/yaml_private.h
  510. --- ruby-2.1.0/ext/psych/yaml/yaml_private.h 2012-12-05 05:08:17.000000000 +0100
  511. +++ ruby-2.1.2/ext/psych/yaml/yaml_private.h 2014-05-04 17:45:33.000000000 +0200
  512. @@ -10,6 +10,17 @@
  513. #include <assert.h>
  514. #include <limits.h>
  515. +#include <stddef.h>
  516. +
  517. +#ifndef _MSC_VER
  518. +#include <stdint.h>
  519. +#else
  520. +#ifdef _WIN64
  521. +#define PTRDIFF_MAX _I64_MAX
  522. +#else
  523. +#define PTRDIFF_MAX INT_MAX
  524. +#endif
  525. +#endif
  526. /*
  527. * Memory management.
  528. @@ -135,9 +146,12 @@
  529. (string).start = (string).pointer = (string).end = 0)
  530. #define STRING_EXTEND(context,string) \
  531. - (((string).pointer+5 < (string).end) \
  532. + ((((string).pointer+5 < (string).end) \
  533. || yaml_string_extend(&(string).start, \
  534. - &(string).pointer, &(string).end))
  535. + &(string).pointer, &(string).end)) ? \
  536. + 1 : \
  537. + ((context)->error = YAML_MEMORY_ERROR, \
  538. + 0))
  539. #define CLEAR(context,string) \
  540. ((string).pointer = (string).start, \
  541. @@ -422,7 +436,14 @@
  542. (stack).start = (stack).top = (stack).end = 0)
  543. #define STACK_EMPTY(context,stack) \
  544. - ((stack).start == (stack).top)
  545. + ((void)(context), \
  546. + ((stack).start == (stack).top))
  547. +
  548. +#define STACK_LIMIT(context,stack,size) \
  549. + ((stack).top - (stack).start < (size) ? \
  550. + 1 : \
  551. + ((context)->error = YAML_MEMORY_ERROR, \
  552. + 0))
  553. #define PUSH(context,stack,value) \
  554. (((stack).top != (stack).end \