aboutsummaryrefslogtreecommitdiffstats
path: root/common.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-11-15 22:30:17 +0100
committerMattias Andrée <maandree@kth.se>2017-11-15 22:30:17 +0100
commit0b4d1f900045cc8dc02cd7dd111faee52a332504 (patch)
treefa8aa262846f7df0a9a49998520568d7fcc0b4ff /common.c
parentFix arg.h (diff)
downloadsha3sum-0b4d1f900045cc8dc02cd7dd111faee52a332504.tar.gz
sha3sum-0b4d1f900045cc8dc02cd7dd111faee52a332504.tar.bz2
sha3sum-0b4d1f900045cc8dc02cd7dd111faee52a332504.tar.xz
Fix buffer overflow
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.c')
-rw-r--r--common.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/common.c b/common.c
index 9ef98f8..4fc2cce 100644
--- a/common.c
+++ b/common.c
@@ -148,7 +148,7 @@ generalised_sum_fd_hex(int fd, libkeccak_state_t *restrict state,
{
ssize_t got;
struct stat attr;
- size_t blksize = 4096, r = 0, w = 0;
+ size_t blksize = 4096, r, w;
char *restrict chunk;
char even = 1, buf = 0, c;
@@ -166,6 +166,7 @@ generalised_sum_fd_hex(int fd, libkeccak_state_t *restrict state,
return -1;
if (!got)
break;
+ r = w = 0;
while (r < (size_t)got) {
c = chunk[r++];
if (c <= ' ')