Hi,
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: =========
/lib/libc.so.6(__fortify_fail+0x45)[0xb7638055]
/lib/libc.so.6(+0x10000a)[0xb763800a]
* 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,
#else
        'u',    __ifmt,
#endif

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

Reply via email to