Mercurial > hg
comparison mercurial/parsers.c @ 26590:473a63c45394
parsers: read sizes of metadata pair of obsolete marker at once
This will make it easy to implement bound checking. Currently fm1readmarker()
has no protection for corrupted obsstore and can cause infinite loop or
out-of-bound reads.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 11 Oct 2015 18:41:41 +0900 |
parents | 46605888faf3 |
children | 042344313939 |
comparison
equal
deleted
inserted
replaced
26589:fb388aa26453 | 26590:473a63c45394 |
---|---|
2628 if (metadata == NULL) { | 2628 if (metadata == NULL) { |
2629 goto bail; | 2629 goto bail; |
2630 } | 2630 } |
2631 for (i = 0; i < nmetadata; i++) { | 2631 for (i = 0; i < nmetadata; i++) { |
2632 PyObject *tmp, *left = NULL, *right = NULL; | 2632 PyObject *tmp, *left = NULL, *right = NULL; |
2633 Py_ssize_t metasize = (unsigned char)(*data++); | 2633 Py_ssize_t leftsize = (unsigned char)(*data++); |
2634 left = PyString_FromStringAndSize(meta, metasize); | 2634 Py_ssize_t rightsize = (unsigned char)(*data++); |
2635 meta += metasize; | 2635 left = PyString_FromStringAndSize(meta, leftsize); |
2636 metasize = (unsigned char)(*data++); | 2636 meta += leftsize; |
2637 right = PyString_FromStringAndSize(meta, metasize); | 2637 right = PyString_FromStringAndSize(meta, rightsize); |
2638 meta += metasize; | 2638 meta += rightsize; |
2639 tmp = PyTuple_New(2); | 2639 tmp = PyTuple_New(2); |
2640 if (!left || !right || !tmp) { | 2640 if (!left || !right || !tmp) { |
2641 Py_XDECREF(left); | 2641 Py_XDECREF(left); |
2642 Py_XDECREF(right); | 2642 Py_XDECREF(right); |
2643 Py_XDECREF(tmp); | 2643 Py_XDECREF(tmp); |