Can be reproduced with this command:
srec_cat -generate 0 1 -constant 0 -random-fill 0xFFFFFFFE 0xFFFFFFFF
---
Makefile.in | 8 ++++--
srecord/input/filter/random_fill.cc | 6 ++++-
test/02/t0256a.sh | 49 +++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 3 deletions(-)
create mode 100644 test/02/t0256a.sh
diff --git a/Makefile.in b/Makefile.in
index 400b933..952ee4b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -3716,6 +3716,9 @@ t0254a: all test/02/t0254a.sh
t0255a: all test/02/t0255a.sh
PATH=`pwd`/bin:$$PATH $(SH) test/02/t0255a.sh
+t0256a: all test/02/t0256a.sh
+ PATH=`pwd`/bin:$$PATH $(SH) test/02/t0256a.sh
+
test/arglex_ambiguous/main.lo test/arglex_ambiguous/main.o: srecord/arglex.h \
srecord/arglex/tool.h srecord/defcon.h srecord/endian.h \
srecord/format_printf.h srecord/input.h srecord/output.h \
@@ -4157,7 +4160,7 @@ test_files = t0001a t0002a t0003a t0004a t0005a t0006a t0007a t0008a t0009a \
t0206a t0207a t0209a t0210a t0211a t0212a t0213a t0215a t0216a \
t0217a t0218a t0219a t0220a t0221a t0222a t0223a t0225a t0227a \
t0228a t0229a t0230a t0231a t0232a t0233a t0235a t0236a t0237a \
- t0238a t0239a t0250a t0251a t0253a t0254a t0255a
+ t0238a t0239a t0250a t0251a t0253a t0254a t0255a t0256a
sure: $(test_files)
@echo Passed All Tests
@@ -4821,6 +4824,7 @@ uninstall:
t0207a t0209a t0210a t0211a t0212a t0213a t0215a t0216a t0217a \
t0218a t0219a t0220a t0221a t0222a t0223a t0225a t0227a t0228a \
t0229a t0230a t0231a t0232a t0233a t0235a t0236a t0237a t0238a \
- t0239a t0250a t0251a t0253a t0254a t0255a the-default-target
+ t0239a t0250a t0251a t0253a t0254a t0255a t0256a \
+ the-default-target
# vim: set ts=8 sw=8 noet :
diff --git a/srecord/input/filter/random_fill.cc b/srecord/input/filter/random_fill.cc
index bdd1f84..6df7ddb 100644
--- a/srecord/input/filter/random_fill.cc
+++ b/srecord/input/filter/random_fill.cc
@@ -50,7 +50,11 @@ srecord::input_filter_random_fill::generate(srecord::record &record)
if (range.empty())
return false;
unsigned char buffer[srecord::record::max_data_length];
- interval chunk(range.get_lowest(), range.get_lowest() + sizeof(buffer));
+ interval::data_t lo = range.get_lowest();
+ interval::data_t hi = lo + sizeof(buffer);
+ if (hi < lo)
+ hi = 0;
+ interval chunk(lo, hi);
chunk *= range;
chunk.first_interval_only();
int nbytes = chunk.get_highest() - chunk.get_lowest();
diff --git a/test/02/t0256a.sh b/test/02/t0256a.sh
new file mode 100644
index 0000000..b68309d
--- /dev/null
+++ b/test/02/t0256a.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# srecord - The "srecord" program.
+# Copyright (C) 2007, 2008, 2011 Peter Miller
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+TEST_SUBJECT="random fill near end of address space"
+. test_prelude
+
+cat > test.ok << 'fubar'
+Format: Motorola S-Record
+Header: "HDR"
+Execution Start Address: 00000000
+Data: 00000000 - 00000000
+ FFFFFFFE - FFFFFFFE
+fubar
+if test $? -ne 0; then no_result; fi
+
+srec_cat -generate 0 1 -constant 0 -random-fill 0xFFFFFFFE 0xFFFFFFFF \
+ -o test.srec -header HDR -start-addr 0
+if test $? -ne 0; then fail; fi
+
+srec_info test.srec > test.out
+if test $? -ne 0; then fail; fi
+
+diff test.ok test.out
+if test $? -ne 0; then fail; fi
+
+#
+# The things tested here, worked.
+# No other guarantees are made.
+#
+pass
+
+# vim: set ts=8 sw=4 et :
--
2.0.4
|