summaryrefslogtreecommitdiff
path: root/hex.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2016-09-01 12:54:31 -0700
committerGary E. Miller <gem@rellim.com>2016-09-01 12:54:31 -0700
commitd74eaab05f1bc9ea6ddb44c54a98deef6872e43c (patch)
tree54ab2c8d978b8e19908f3f9af597d3d7998887f8 /hex.c
parent902b4618f20607e7bc78fd29071118f315eef23d (diff)
downloadgpsd-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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hex.c b/hex.c
index e03ddc97..80f0009a 100644
--- a/hex.c
+++ b/hex.c
@@ -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];
}