50 lines
1.4 KiB
Diff
50 lines
1.4 KiB
Diff
From 33ff2b0de5e9bd556b64fa8e0c20dbb72c41c0fc Mon Sep 17 00:00:00 2001
|
|
From: grajagandev <dmoorefo@gmail.com>
|
|
Date: Mon, 8 Feb 2016 07:58:45 -0800
|
|
Subject: [PATCH 2/4] Fix signed integer overflow - big block sizes
|
|
|
|
---
|
|
src/main.c | 2 +-
|
|
tests/Makefile.am | 3 ++-
|
|
tests/testsuite.at | 1 +
|
|
3 files changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git src/main.c src/main.c
|
|
index a13861f..5a30a7b 100644
|
|
--- src/main.c
|
|
+++ src/main.c
|
|
@@ -321,7 +321,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
|
|
|
case BLOCK_SIZE_OPTION: /* --block-size */
|
|
io_block_size = atoi (arg);
|
|
- if (io_block_size < 1)
|
|
+ if (io_block_size < 1 || io_block_size > INT_MAX/512)
|
|
USAGE_ERROR ((0, 0, _("invalid block size")));
|
|
io_block_size *= 512;
|
|
break;
|
|
diff --git tests/Makefile.am tests/Makefile.am
|
|
index 2fbee29..863f46c 100644
|
|
--- tests/Makefile.am
|
|
+++ tests/Makefile.am
|
|
@@ -55,7 +55,8 @@ TESTSUITE_AT = \
|
|
symlink-bad-length.at\
|
|
symlink-long.at\
|
|
symlink-to-stdout.at\
|
|
- version.at
|
|
+ version.at\
|
|
+ big-block-size.at
|
|
|
|
TESTSUITE = $(srcdir)/testsuite
|
|
|
|
diff --git tests/testsuite.at tests/testsuite.at
|
|
index 81e205b..b11c4a0 100644
|
|
--- tests/testsuite.at
|
|
+++ tests/testsuite.at
|
|
@@ -42,3 +42,4 @@ m4_include([setstat02.at])
|
|
m4_include([setstat03.at])
|
|
m4_include([setstat04.at])
|
|
m4_include([setstat05.at])
|
|
+m4_include([big-block-size.at])
|
|
--
|
|
2.20.1
|
|
|