Re: [Libguestfs] Issue with downloading files whose path contains multi-byte utf-8 characters

2023-02-14 Thread Yonatan Shtarkman
Thanks Richard! The patches are similar to what we did locally, and applying them fixed the issue with the actual use-case (not just the sanitized repro). On Tue, Feb 14, 2023 at 8:10 PM Richard W.M. Jones wrote: > On Tue, Feb 14, 2023 at 08:02:59PM +0200, Yonatan Shtarkman wrote: > > The

[Libguestfs] [PATCH 2/2] python: Use bytes instead of str for event callback buffer

2023-02-14 Thread Richard W.M. Jones
The event callback gets a buffer parameter which is usually something like a log message. However as it comes from C it is not necessarily well-formed (eg) UTF-8 but could contain any old byte sequence. In the test case provided by the reported, we failed to encode the buffer as str with this

[Libguestfs] [PATCH 1/2] python: Avoid crash if callback parameters cannot be built

2023-02-14 Thread Richard W.M. Jones
In the case that building the parameters to the Python event callback fails, args was returned as NULL. We immediately tried to call Py_INCREF on this which crashed. Returning NULL means the Python function threw an exception, so print the exception and return (there is no way to return an error

Re: [Libguestfs] Issue with downloading files whose path contains multi-byte utf-8 characters

2023-02-14 Thread Richard W.M. Jones
On Tue, Feb 14, 2023 at 08:02:59PM +0200, Yonatan Shtarkman wrote: > The attached code snippetĀ reproduces the issue when running: > python3 libugestfs_segfault_repro.py > > With: > guestfs version: 1.48.6 > guestfs-python version: 1.48.6 Can confirm with

Re: [Libguestfs] Issue with downloading files whose path contains multi-byte utf-8 characters

2023-02-14 Thread Yonatan Shtarkman
The attached code snippet reproduces the issue when running: python3 libugestfs_segfault_repro.py With: guestfs version: 1.48.6 guestfs-python version: 1.48.6 Stacktrace: #0 0x7f6dd17b4701 in _Py_INCREF (op=) at /usr/include/python3.9/object.h:408 408op->ob_refcnt++; (gdb) bt #0