Hello,
not being the maintainer for this package, I just tried to
have a look at it.


1043                   *str = EquivalTable[ *str++ ] ;


To me it looks like in the past the compiler did the assignment
to the unincremented str.
Today str gets first incremented, then *str assigned the element
from EquivalTable.
That way the next char, termination and following memory gets
overwritten until inaccessible memory is reached.


Attached patch moves the increment explicitly after the assignment.

Additional patch adds debug information to the gcc command.
That way the automatic dbgsym packages should get usable.


Kind regards,
Bernhard



bernhard@rechner:~/le-dico-de-rene-cougnenc-1.3/src$ gdb -q --args ./dico test
Reading symbols from ./dico...done.
(gdb) run
Starting program: /home/bernhard/le-dico-de-rene-cougnenc-1.3/src/dico test

DICO V 1.3 (linux) - R.Cougnenc 1992


Program received signal SIGSEGV, Segmentation fault.
0x0000555555556159 in StrAscii (str=0x555555779000 <error: Cannot access memory 
at address 0x555555779000>) at dico.c:1043
1043                   *str = EquivalTable[ *str++ ] ;
(gdb) bt
#0  0x0000555555556159 in StrAscii (str=0x555555779000 <error: Cannot access 
memory at address 0x555555779000>) at dico.c:1043
#1  0x0000555555555779 in lookfor (pattern=0x55555575db20 't' <repeats 200 
times>...) at dico.c:413
#2  0x0000555555554fb6 in main (argc=1, argv=0x7fffffffdcb8) at dico.c:185
(gdb)
From cd187a08787f5adc737db882d9ee4e32e1146446 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernha...@mailbox.org>
Date: Sat, 28 Jan 2017 13:23:10 +0100
Subject: Compile with debug information. Make dbgsym package work.

---
 src/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 2da574e..0624fee 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,8 +2,8 @@
 prefix = /usr
 
 dico: dico.c killposte.c
-	gcc dico.c -o dico
-	gcc killposte.c -o killposte
+	gcc -g dico.c -o dico
+	gcc -g killposte.c -o killposte
 
 clean:
 	rm -fr *~ dico killposte *.1 manpage.links manpage.refs
-- 
2.11.0

From 838e001653d3d9a17b344836368df0b3b1b40499 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=83=C2=9Cbelacker?= <bernha...@mailbox.org>
Date: Sat, 28 Jan 2017 13:31:56 +0100
Subject: Increment str explicitly after assignment.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=852659
---
 src/dico.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/dico.c b/src/dico.c
index 6b72c68..eedd6e2 100644
--- a/src/dico.c
+++ b/src/dico.c
@@ -1040,7 +1040,8 @@ StrAscii ( byte *str)
  
     while (*str)
     {
-               *str = EquivalTable[ *str++ ] ;
+               *str = EquivalTable[ *str ] ;
+               str++;
     }
 
  return p ;
-- 
2.11.0

Reply via email to