Opened 5 years ago

Closed 5 years ago

#11322 closed bug (fixed)

Bash crash in iswprint while running haikuporter

Reported by: pulkomandy Owned by: zooey
Priority: normal Milestone: R1
Component: System/libroot.so Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description (last modified by pulkomandy)

./haikuporter album

or

./haikuporter --lint

bash crashes when parsing recipes which have unicode characters (in the case of album, in the copyright). This was apparently introduced when outsourcing bash.

There is no gLocaleRoster in this case, and iswprint tries to use the 384-entries flag table for the unicode char, but this results in an out of range access for any non-ASCII char.

So there are two bugs:

  • gLocaleRoster shouldn't be NULL (I have tried reproducing the issue out of HaikuPorter, and indeed it isn't NULL in that case)
  • The functions should not crash when gLocaleRoster is NULL and they are fed an unicode character.

One way to fix the latter is to add bounds checks to __isctype and always return false for out of range characters. But I think it's better to investigate the first issue first.

Change History (3)

comment:1 by korli, 5 years ago

I've met the issue on x86_64, I wasn't sure it was specific to this arch. FWIW isprint() checks the bounds, it's also a necessary step for isw* functions because the POSIX locale doesn't require a locale backend, hence the fallback on __isctype.

Last edited 5 years ago by pulkomandy (previous) (diff)

comment:2 by pulkomandy, 5 years ago

Description: modified (diff)

comment:3 by pulkomandy, 5 years ago

Description: modified (diff)
Resolution: fixed
Status: newclosed

Fixed in hrev47966 then.

Note: See TracTickets for help on using tickets.