If the start address of a partial record is >= 0xFFFFFFF1, there is a
u32 overflow when adding 255 (the maximum record data length). But the
result with this address is still correct (see documentation "If the
maximum is given as zero then the range extends to the end of the
address space."), the endless loop appears when using address 0xFFFFFFF2
or higher.
Can be reproduced with this command:
srec_cat -generate 0xFFFFFF02 0xFFFFFF03 -constant 0xAB
Giving this warning messages:
srec_cat: constant 0xAB: warning: data records not in strictly ascending order
(expected >= 0x100000000, got 0xFFFFFF02)
srec_cat: constant 0xAB: warning: redundant 0xFFFFFF02 value (0xAB)
srec_cat: constant 0xAB: warning: redundant 0xFFFFFF03 value (0xAB)
[...]
srec_cat: constant 0xAB: warning: redundant 0xFFFFFFFF value (0xAB)
srec_cat: constant 0xAB: warning: redundant 0xFFFFFF02 value (0xAB)
[...]
---
Makefile.in | 7 +++++--
srecord/input/generator.cc | 5 ++++-
test/02/t0254a.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 3 deletions(-)
create mode 100644 test/02/t0254a.sh
diff --git a/Makefile.in b/Makefile.in
index 9bdd8f1..d2ad740 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -3710,6 +3710,9 @@ t0251a: all test/02/t0251a.sh
t0253a: all test/02/t0253a.sh
PATH=`pwd`/bin:$$PATH $(SH) test/02/t0253a.sh
+t0254a: all test/02/t0254a.sh
+ PATH=`pwd`/bin:$$PATH $(SH) test/02/t0254a.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 \
@@ -4151,7 +4154,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
+ t0238a t0239a t0250a t0251a t0253a t0254a
sure: $(test_files)
@echo Passed All Tests
@@ -4815,6 +4818,6 @@ 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 the-default-target
+ t0239a t0250a t0251a t0253a t0254a the-default-target
# vim: set ts=8 sw=8 noet :
diff --git a/srecord/input/generator.cc b/srecord/input/generator.cc
index 42fd5ef..870c18b 100644
--- a/srecord/input/generator.cc
+++ b/srecord/input/generator.cc
@@ -54,7 +54,10 @@ srecord::input_generator::read(srecord::record &result)
// biggest record size available.
//
unsigned long addr = range.get_lowest();
- interval partial(addr, addr + srecord::record::max_data_length);
+ uint32_t end = addr + srecord::record::max_data_length;
+ if (end < addr)
+ end = 0xFFFFFFFF;
+ interval partial(addr, end);
partial *= range;
//
diff --git a/test/02/t0254a.sh b/test/02/t0254a.sh
new file mode 100644
index 0000000..bff7216
--- /dev/null
+++ b/test/02/t0254a.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# srecord - Manipulate EPROM load files
+# Copyright (C) 2009, 2011, 2012 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="generate near end of address space"
+. test_prelude
+
+cat > test.ok << 'fubar'
+S00600004844521B
+S306FFFFFF02AB4F
+S5030001FB
+fubar
+if test $? -ne 0; then no_result; fi
+
+srec_cat -generate 0xFFFFFF02 0xFFFFFF03 -constant 0xAB -o test.out -header HDR
+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
|