package hexer
tag 540571 + confirmed pending
thanks
On Sun, Aug 09, 2009 at 08:09:52PM -0400, Michael Gold wrote:
> Here's the gdb output after rebuilding it with debug symbols:
>
> Program received signal SIGSEGV, Segmentation fault.
[snip]
> #3 0x00407cdc in tio_vprintf (fmt=0x42ab95 "%s", ap=0x7fffe4c0)
> at tio.c:2098
> #4 0x00407c86 in tio_printf (fmt=0x42ab95 "%s") at tio.c:2078
I think I found it; thanks for the bug report, it would never have
crossed my mind to examine this particular piece of the hexer code
to see what devilish magic it does behind the curtain!
I've fixed it in my Subversion repository, and I'll release hexer-0.1.5
(adopting the upstream) soon. In the meantime, could you try dropping
the attached file into debian/patches/ and adding it to "series" to
see if it helps?
Once again, thanks for the bug report and the backtrace!
G'luck,
Peter
--
Peter Pentchev r...@ringlet.netr...@space.bgr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553
This sentence contradicts itself - or rather - well, no, actually it doesn't!
The v*printf() routines may NOT be invoked a second time over the same
varargs list. Avoid undefined behavior by simply using vasprintf()
which has been available on Linux, among other systems, for a long time.
A more portable fix will be included in hexer-0.1.5.
--- a/tio.c
+++ b/tio.c
@@ -542,6 +542,7 @@
}
/* tio_isprint */
+#if 0
#if USE_STDARG
int
nprintf(const char *fmt, ...)
@@ -580,6 +581,7 @@
return vfprintf(null, fmt, ap);
}
/* vnprintf */
+#endif
#if USE_STDARG
static void
@@ -2092,11 +2094,11 @@
*/
{
char *s;
- int rval, len;
+ int rval;
- len = vnprintf(fmt, ap);
- rval = vsprintf(s = (char *)malloc(len + 1), fmt, ap);
- s[len] = 0;
+ rval = vasprintf(&s, fmt, ap);
+ if (rval == -1)
+return rval;
tio_display(s, 0);
free((char *)s);
return rval;
@@ -2135,11 +2137,11 @@
*/
{
char *s;
- int rval, len;
+ int rval;
- len = vnprintf(fmt, ap);
- rval = vsprintf(s = (char *)malloc(len + 1), fmt, ap);
- s[len] = 0;
+ rval = vasprintf(&s, fmt, ap);
+ if (rval == -1)
+return rval;
tio_puts(s);
free((char *)s);
return rval;
--- a/tio.h
+++ b/tio.h
@@ -113,6 +113,7 @@
extern
tio_isprint( /* int x */ );
+#if 0
extern
#if USE_STDARG
nprintf( const char *fmt, ... );
@@ -125,6 +126,7 @@
/* Returns the number of output characters a call to a printf-like function
* would pruduce.
*/
+#endif
extern
tio_init( /* char *program_name */ );
pgpqzeh8YW8nc.pgp
Description: PGP signature