coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

coreutils: fixed panic when multi-call binary has funny name

Open BartMassey opened this issue 2 years ago • 3 comments

The multi-call coreutils binary starts by trying to convert its invocation path into a UTF-8 string, panicking if this doesn't work.

This patch makes coreutils exit gracefully in this case.

BartMassey avatar Feb 14 '23 08:02 BartMassey

Cool, thanks. Would it be possible to write a test to make sure we don't regress in the future ?

sylvestre avatar Feb 14 '23 08:02 sylvestre

To be honest, I'm not sure what test would be worth inserting here. As long as name() returns an Option, I think things are good.

Any reasonable test would have to manipulate the host filesystem in odd ways, and would be unlikely to be very portable.

I'll think about what might be done.

BartMassey avatar Feb 14 '23 09:02 BartMassey

Maybe an integration test that just calls the binary with invalid utf-8 in this file: https://github.com/uutils/coreutils/blob/main/tests/test_util_name.rs?

Edit: Nevermind that's still difficult.

tertsdiepraam avatar Feb 15 '23 11:02 tertsdiepraam

Thanks!

BartMassey avatar Apr 28 '23 10:04 BartMassey

Thank you and sorry for the latency !

sylvestre avatar Apr 28 '23 14:04 sylvestre