[Toybox] [landley/toybox] Segfault using toybox stat on Android emulator (#36)

Rob Landley rob at landley.net
Wed Aug 17 11:12:31 PDT 2016


On 08/11/2016 04:08 AM, Matthias Urhahn wrote:
> Can reproduce this with toybox 0.7.1 build against 2016.03 buildroot on
> a Nexus5 at 6.0.1.
> 
> |root at hammerhead:/sdcard # toybox_sdm stat -c "%u"
> twrp-3.0.0-0-hammerhead.img < 0 root at hammerhead:/sdcard # toybox_sdm
> stat -c "%U" twrp-3.0.0-0-hammerhead.img < Segmentation fault
> root at hammerhead:/sdcard # toybox_sdm stat -c "%g"
> twrp-3.0.0-0-hammerhead.img < 1015 root at hammerhead:/sdcard # toybox_sdm
> stat -c "%G" twrp-3.0.0-0-hammerhead.img < Segmentation fault
> 139|root at hammerhead:/sdcard # |
> 
> I would guess resolving/lookup of group id or user id (names?) causes
> the segfault.

I think I've fixed this now, and as of commit 05e1582ec435 I think I've
added "%123s" support to all the entries except %N, which is funky:

$ ln -s blat boing
$ stat -c '%18n' boing
             boing
$ toybox stat -c '%18n' boing
             boing
$ stat -c '%18N' boing
       ‘boing’ ->         ‘blat’
$ toybox stat -c '%18N' boing
`boing' -> `blat'
$ stat -c '%-18NX' boing
‘boing’        -> ‘blat’        X

For %n, both are indenting boing by 13 to get 18 (which is what %18s
does given a 5 character string).

But for %18N the Ubuntu version is indenting _both_ parts, the first
indented 7 and the second indented 8 (one space after the > is normal),
and I'm not even going to try to GUESS at the logic of this? I added the
negative version with the %X at the end as a quick "does that make more
sense" check. I could try versions where the symlink name and the
filename it points to are wildly different sizes. But in general: what?

Ordinarily %42s right justifies. That behavior is pretty simple, and I
implemented it here. But %N isn't doing that, it's doing something
fancier, and there's no spec, and for the moment I'm just _ignoring_ the
pad length rather than go there.

Open to suggestions,

Rob


More information about the Toybox mailing list