Swish-e 2.4.3 doesn't work with OpenBSD 3.8: there is a SEGFAULT when it's
trying to parse a config file (swish-e -c tests/test.config).
However the bug is simple.
In the file src/parse_conffile.c, the function read_line_from_file reads
lines from the config file. This is a simplified extract from the function:
--->
buf_size = LINE_BUF_LEN * sizeof( char );
line = emalloc( buf_size );
if ( !fgets( &(line[cur_len]), LINE_BUF_LEN, fp ) )
break;
cur_len = strlen( line );
if ( line[cur_len-2] == '\\' && line[cur_len-1] == '\n' )
line[cur_len-2] = '\0';
<---
If the line is a blank line (for example the second line of test.config),
strlen(line) returns 1 (char '\n').
In this case:
- line[cur_len-1] -> line[0] = '\n'
- line[cur_len-2] -> out of the buffer -> SEGFAULT
I propose this patch:
--- parse_conffile.c Wed Jan 11 22:47:52 2006
+++ parse_conffile_correct.c Wed Jan 11 23:49:28 2006
@@ -1740,6 +1740,7 @@
/* Look for continuation mark (backslash+\n) and replace with space
*/
cur_len = strlen( line );
+ if ( cur_len < 2 ) break;
if ( line[cur_len-2] == '\\' && line[cur_len-1] == '\n' )
line[cur_len-2] = '\0';
else
Aurélien.
PS: thank you to the OpenBSD team to have introduced a new malloc method.
More information:
http://marc.theaimsgroup.com/?l=openbsd-misc&m=112475373731469&w=2
http://undeadly.org/cgi?action=article&sid=20051224192032
Received on Wed Jan 11 14:07:53 2006