Aleksander Piotrowski wrote:
It does not core dump on sparc64. In i386 it gets a SIGSEGV in get_conf().
Ok?
Ok, but....
It's one more hack that works around the real problem. We begin
to add tests to make sure indices are not negative instead of solving
the real problem, i.e. to make sure those indices are not negative in
the first place.
The patch is ok for me, as a temporary hack, but I think we should
really go deeper into matters, find out why the indices are wrong and
submit patches upstream.
The new mmap based malloc() is a congenious tool to find bugs, I really
like it. Let's use it, not just to find and add kludges, but to really
make software better.
diff -urN beaver/Makefile beaver.new/Makefile
--- beaver/Makefile Wed Nov 24 12:08:02 2004
+++ beaver.new/Makefile Sat Aug 27 23:03:23 2005
@@ -2,6 +2,7 @@
COMMENT= "lightweight Gtk text editor with syntax highlighting"
DISTNAME= beaver-0.2.7
+PKGNAME= ${DISTNAME}p0
CATEGORIES= editors
HOMEPAGE= http://www.nongnu.org/beaver/
Binary files beaver/beaver.core and beaver.new/beaver.core differ
diff -urN beaver/patches/patch-src_conf_c beaver.new/patches/patch-src_conf_c
--- beaver/patches/patch-src_conf_c Thu Jan 1 01:00:00 1970
+++ beaver.new/patches/patch-src_conf_c Sat Aug 27 22:55:01 2005
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- src/conf.c.orig Sat Aug 27 22:54:54 2005
++++ src/conf.c Sat Aug 27 22:54:27 2005
+@@ -157,7 +157,7 @@ gint get_conf(gchar *key, t_conf *conf)
+ for (i = 0; conf->file_content[i]; i++)
+ for (j = 0; conf->file_content[i][j]; j++)
+ if (conf->file_content[i][j] == COMMENT &&
+- (conf->file_content[i][j - 1] != '\\' || !j))
++ (!j || conf->file_content[i][j - 1] != '\\'))
+ {
+ conf->file_content[i][j] = '\0';
+ break;