Changeset 75762e5f in subsurface


Ignore:
Timestamp:
May 7, 2017, 7:48:12 AM (7 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
d7cf340
Parents:
47dcc96
git-author:
Salvador Cuñat <salvador.cunat@…> (05/07/17 05:26:56)
git-committer:
Dirk Hohndel <dirk@…> (05/07/17 07:48:12)
Message:

Datatrak import rework: Add another memory size ckeck

As a last minute addition, and for peace of mind and soul, add just
another size check, to run before reading values from buffer.

Signed-off-by: Salvador Cuñat <salvador.cunat@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/datatrak.h

    r618cd3f r75762e5f  
    4545
    4646#define JUMP(_ptr, _n) if ((long) (_ptr += _n) > maxbuf) goto bail
    47 
     47#define CHECK(_ptr, _n) if ((long) _ptr + _n > maxbuf) goto bail
    4848#define read_bytes(_n) \
    4949        switch (_n) { \
    5050                case 1: \
     51                        CHECK(membuf, _n); \
    5152                        tmp_1byte = membuf[0]; \
    5253                        break; \
    5354                case 2: \
     55                        CHECK(membuf, _n); \
    5456                        tmp_2bytes = two_bytes_to_int (membuf[1], membuf[0]); \
    5557                        break; \
    5658                default: \
     59                        CHECK(membuf, _n); \
    5760                        tmp_4bytes = four_bytes_to_long(membuf[3], membuf[2], membuf[1], membuf[0]); \
    5861                        break; \
     
    6164
    6265#define read_string(_property) \
     66        CHECK(membuf, tmp_1byte); \
    6367        unsigned char *_property##tmp = (unsigned char *)calloc(tmp_1byte + 1, 1); \
    6468        _property##tmp = memcpy(_property##tmp, membuf, tmp_1byte);\
Note: See TracChangeset for help on using the changeset viewer.