bglibs: str_findlast(), ibuf_getstr_crlf()
Gerrit Pape <[email protected]> Wed, 20 Jul 2005 08:09:04 +0000
| Newsgroups | gmane.comp.sysutils.bgware |
|---|---|
| Message-ID | <20050720080907.23601.qmail@1661e78a62e81e.315fe32.mid.smarden.org> |
Hi, the mailfront package built against bglibs-1.024 fails some selftests on Debian alpha and ia64[0] due to the corresponding programs segfaulting; not sure why only on these architectures. The problem seems to be in the bglibs, see the two patches below. I successfully tested them on ia64. Regards, Gerrit. [0] http://buildd.debian.org/fetch.php?&pkg=mailfront&ver=0.96-1&arch=alpha&stamp=1121634413&file=log&as=raw http://buildd.debian.org/fetch.php?&pkg=mailfront&ver=0.96-1&arch=ia64&stamp=1121634099&file=log&as=raw --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
findprev-in-empty.diff
(text/plain, 962 B)
diff -ur bglibs-1.024.orig/str/findprev.c bglibs-1.024/str/findprev.c
--- bglibs-1.024.orig/str/findprev.c 2005-07-11 04:47:36.000000000 +0000
+++ bglibs-1.024/str/findprev.c 2005-07-18 12:51:50.000000000 +0000
@@ -21,6 +21,7 @@
int str_findprev(const str* s, char ch, unsigned pos)
{
char* p;
+ if (! s->len) return -1;
if (pos >= s->len) pos = s->len - 1;
for (p = s->s + pos; p >= s->s; --p)
if (*p == ch) return p - s->s;
@@ -32,11 +33,13 @@
void selftest(void)
{
str s = { "01234567890123456", 16, 0 };
+ str t = { "", 0, 0 };
obuf_puti(&outbuf, str_findprev(&s, '6', 10)); NL();
obuf_puti(&outbuf, str_findprev(&s, '6', 6)); NL();
obuf_puti(&outbuf, str_findprev(&s, '6', 5)); NL();
obuf_puti(&outbuf, str_findprev(&s, '4', -1)); NL();
obuf_puti(&outbuf, str_findprev(&s, '6', -1)); NL();
+ obuf_puti(&outbuf, str_findprev(&t, 'X', -1)); NL();
}
#endif
#ifdef SELFTEST_EXP
@@ -45,4 +48,5 @@
-1
14
6
+-1
#endif
ibuf_getstr_crlf-empty.diff
(text/plain, 475 B)
diff -ur bglibs-1.024.orig/iobuf/ibuf_getstr_crlf.c bglibs-1.024/iobuf/ibuf_getstr_crlf.c --- bglibs-1.024.orig/iobuf/ibuf_getstr_crlf.c 2005-07-11 04:47:36.000000000 +0000 +++ bglibs-1.024/iobuf/ibuf_getstr_crlf.c 2005-07-18 13:01:47.000000000 +0000 @@ -10,7 +10,7 @@ /* Strip the trailing LF */ len = s->len-1; /* Strip a trailing CRs if present */ - if (s->s[len-1] == CR) --len; + if (len && s->s[len-1] == CR) --len; str_truncate(s, len); return 1; }