From b51a9bc2906d9626965d0f13697de7a45d91cf88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 7 Jan 2013 17:42:05 +0100 Subject: [PATCH 1/2] Fix off-by-one error when initializing yap_flags --- ...ne-error-when-initializing-yap_flags.patch | 27 +++++++++++++++++++ yap.spec | 8 +++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch diff --git a/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch b/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch new file mode 100644 index 0000000..e0b59a5 --- /dev/null +++ b/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch @@ -0,0 +1,27 @@ +From 1fba7f121d0f3e93faa94be4dbeba383176717f6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 7 Jan 2013 17:31:08 +0100 +Subject: [PATCH] Off-by-one error when initializing yap_flags + +The yap_flags_field of all_heap_codes structure is of type +Int[LAST_FLAG], thus the loop should iterate from 0 to LAST_FLAG - 1. +--- + C/init.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/C/init.c b/C/init.c +index dda09cc..8f01864 100755 +--- a/C/init.c ++++ b/C/init.c +@@ -1348,7 +1348,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s + Yap_InitTime (); + /* InitAbsmi must be done before InitCodes */ + /* This must be done before initialising predicates */ +- for (i = 0; i <= LAST_FLAG; i++) { ++ for (i = 0; i < LAST_FLAG; i++) { + yap_flags[i] = 0; + } + #ifdef MPW +-- +1.7.11.7 + diff --git a/yap.spec b/yap.spec index f63fde3..205b107 100644 --- a/yap.spec +++ b/yap.spec @@ -4,7 +4,7 @@ Name: yap Version: 6.2.2 -Release: 3%{?dist} +Release: 4%{?dist} Summary: High-performance Prolog Compiler Group: Development/Languages # README Perl Artistic license 2 and the FSF's LGPL @@ -27,6 +27,8 @@ Patch7: yap-6.2.0-Do-not-install-info-dir-index.patch Patch8: yap-6.2.0-gprof-macro.patch # Fix compilation of PLStream package on PPC Patch9: yap-6.2.0-Remove-feature-macro.patch +# Reported to upstream +Patch10: yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch # yap 6.2.2 does not work on PPC (bug #790625) ExcludeArch: ppc ppc64 BuildRequires: autoconf @@ -83,6 +85,7 @@ Documentation for Yap. %patch7 -p1 -b .do_not_install_info_index %patch8 -p1 -b .macro %patch9 -p1 -b .remove_feature_macro +%patch10 -p1 -b .initialization # remove redundant RPATH sed -i 's/-Wl,-R\(,\)\{0,1\}\\$(LIBDIR)//' configure.in @@ -223,6 +226,9 @@ fi %changelog +* Mon Jan 07 2013 Petr Pisar - 6.2.2-4 +- Fix off-by-one error when initializing yap_flags + * Thu Feb 23 2012 Petr Pisar - 6.2.2-3 - yap 6.2.2 does not work on PPC (bug #790625) From 700ebc5fb9dc8a597135509332fac016beaaa14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 7 Jan 2013 18:07:53 +0100 Subject: [PATCH 2/2] Complete fix for accessing yap_flags array --- ...ne-error-when-initializing-yap_flags.patch | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch b/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch index e0b59a5..a376743 100644 --- a/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch +++ b/yap-6.2.2-Off-by-one-error-when-initializing-yap_flags.patch @@ -1,4 +1,4 @@ -From 1fba7f121d0f3e93faa94be4dbeba383176717f6 Mon Sep 17 00:00:00 2001 +From fa8f0f7b2d107770ae4d37bc77c902eafc59c86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 7 Jan 2013 17:31:08 +0100 Subject: [PATCH] Off-by-one error when initializing yap_flags @@ -6,8 +6,9 @@ Subject: [PATCH] Off-by-one error when initializing yap_flags The yap_flags_field of all_heap_codes structure is of type Int[LAST_FLAG], thus the loop should iterate from 0 to LAST_FLAG - 1. --- - C/init.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + C/init.c | 2 +- + C/stdpreds.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C/init.c b/C/init.c index dda09cc..8f01864 100755 @@ -22,6 +23,19 @@ index dda09cc..8f01864 100755 yap_flags[i] = 0; } #ifdef MPW +diff --git a/C/stdpreds.c b/C/stdpreds.c +index a4c0e86..8a4183f 100755 +--- a/C/stdpreds.c ++++ b/C/stdpreds.c +@@ -3637,7 +3637,7 @@ p_access_yap_flags(void) + return(FALSE); + } + flag = IntOfTerm(tflag); +- if (flag < 0 || flag > NUMBER_OF_YAP_FLAGS) { ++ if (flag < 0 || flag >= NUMBER_OF_YAP_FLAGS) { + return(FALSE); + } + #ifdef TABLING -- 1.7.11.7