From d74eaab05f1bc9ea6ddb44c54a98deef6872e43c Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Thu, 1 Sep 2016 12:54:31 -0700 Subject: Fix a potential buffer overrun. Converting from hex to ascii means the out buffer is 2x + 1 the inbuffer. --- hex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hex.c') 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]; } -- cgit v1.2.1