pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pkg/32097
The following reply was made to PR pkg/32097; it has been noted by GNATS.
From: segv%netctl.net@localhost
To: gnats-bugs%NetBSD.org@localhost
Cc: grant%NetBSD.org@localhost
Subject: Re: pkg/32097
Date: Fri, 18 Nov 2005 00:37:39 +0000
OK dudes, I found the problem, it is in libnbcompat/vis.c file
It has the following macro:
#define MAKEEXTRALIST(flag, extra, orig) \
do { \
const char *o = orig; \
char *e; \
while (*o++) \
continue; \
extra = alloca((size_t)((o - orig) + MAXEXTRAS)); \
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
continue; \
e--; \
if (flag & VIS_SP) *e++ = ' '; \
if (flag & VIS_TAB) *e++ = '\t'; \
if (flag & VIS_NL) *e++ = '\n'; \
if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
*e = '\0'; \
} while (/*CONSTCOND*/0)
and then later in the file the macro is called in the following way:
MAKEEXTRALIST(flag, extra, "");
the third argument to the macro causes problems, because it expands to empty
string constants, which are stored at different addresses, so on a big-endian
sparc machine:
extra = alloca((size_t)((o - orig) + MAXEXTRAS));
calls alloca() funcation, passing it a huge number, which overruns the stack
and crashes the program.
Below you can see the different behaviour you get with different compilers
[ultra10] cat test.c
#include <stdio.h>
int main(void)
{
printf("%lu\n", "" - "");
}
[ultra10] gcc test.c
[ultra10] ./a.out
0
[ultra10] /opt/SUNWspro/bin/cc test.c
[ultra10] ./a.out
4294967292
[ultra10]
So, somebody has to fix vis.c file
--- vis.c.orig Fri Nov 18 00:16:26 2005
+++ vis.c Fri Nov 18 00:23:35 2005
@@ -329,10 +329,11 @@
{
char *extra;
+ const char *emptystr = "";
_DIAGASSERT(dst != NULL);
- MAKEEXTRALIST(flag, extra, "");
+ MAKEEXTRALIST(flag, extra, emptystr);
if (flag & VIS_HTTPSTYLE)
HVIS(dst, c, flag, nextc, extra);
else
@@ -359,8 +360,9 @@
int flag;
{
char *extra;
+ const char *emptystr = "";
- MAKEEXTRALIST(flag, extra, "");
+ MAKEEXTRALIST(flag, extra, emptystr);
return (strsvis(dst, src, flag, extra));
}
@@ -373,7 +375,8 @@
int flag;
{
char *extra;
+ const char *emptystr = "";
- MAKEEXTRALIST(flag, extra, "");
+ MAKEEXTRALIST(flag, extra, emptystr);
return (strsvisx(dst, src, len, flag, extra));
}
Home |
Main Index |
Thread Index |
Old Index