diff options
author | Gary E. Miller <gem@rellim.com> | 2016-09-01 12:54:31 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2016-09-01 12:54:31 -0700 |
commit | d74eaab05f1bc9ea6ddb44c54a98deef6872e43c (patch) | |
tree | 54ab2c8d978b8e19908f3f9af597d3d7998887f8 /hex.c | |
parent | 902b4618f20607e7bc78fd29071118f315eef23d (diff) | |
download | gpsd-d74eaab05f1bc9ea6ddb44c54a98deef6872e43c.tar.gz |
Fix a potential buffer overrun.
Converting from hex to ascii means the out buffer is 2x + 1 the
inbuffer.
Diffstat (limited to 'hex.c')
-rw-r--r-- | hex.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -54,7 +54,7 @@ const char *gpsd_hexdump(char *scbuf, size_t scbuflen, if (NULL == binbuf || 0 == binbuflen) return ""; - for (i = 0; i < len && i * 2 < scbuflen - 2; i++) { + for (i = 0; i < len && j < (scbuflen - 3); i++) { scbuf[j++] = hexchar[(ibuf[i] & 0xf0) >> 4]; scbuf[j++] = hexchar[ibuf[i] & 0x0f]; } |