[dev] [9base] the PLAN9PORT C preprocessor definition?

From: Chris Brannon <chris_AT_the-brannons.com>
Date: Mon, 19 Mar 2012 05:53:55 -0500

I package 9base for ArchLinux, and I just learned that the sha1sum binary
is broken. On some systems, it crashes
with an error message like the following:

*** stack smashing detected ***: /opt/plan9/bin/sha1sum_bkp terminated
======= Backtrace: =========
* Lots of inscrutable backtrace deleted *

For me, it runs, but the output is interesting:

# /opt/plan9/bin/sha1sum /bin/ls
# gives output:
1215201216261815999003198215442429362069x /bin/ls

That is obviously incorrect. And what is the x character doing at the
end of the numeric output?
So I looked at sha1sum/sha1sum.c. Here's line 15:
                sprint(buf+2*i, "%.2ux", p[i]);
%.2ux isn't being interpreted correctly.
The problem is in lib9/fmt/fmt.c, lines 62 through 66:

#ifdef PLAN9PORT
        'u', __flagfmt,
        'u', __ifmt,

PLAN9PORT wasn't defined when 9base was built.
Adding -DPLAN9PORT to CFLAGS in config.mk fixed my problem, and sha1sum
works as it should, after the rebuild.

Why isn't -DPLAN9PORT in config.mk already? I'm surprised that this hasn't
caused trouble for anyone else.

-- Chris
Received on Mon Mar 19 2012 - 11:53:55 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 19 2012 - 12:00:07 CET