Syllo / nvtop

GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm
Other
8.04k stars 291 forks source link

interface_options: handle both XDG_CONFIG_HOME and HOME being unset #255

Closed larunbe closed 10 months ago

larunbe commented 10 months ago

When HOME was unset, nvtop would segfault as in the following trace:

Process terminating with default action of signal 11 (SIGSEGV) Access not within mapped region at address 0x0 at 0x488B298: strlen (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so) by 0x119F33: default_config_path (interface_options.c:48) by 0x11A5F3: alloc_interface_options_internals (interface_options.c:138) by 0x10FEBF: main (nvtop.c:209)

We need to handle the unlikely case in which HOME is also unset. On top of that, default_config_path()'s return value has to be checked in the calling function to make sure a default config file's path string is only allocated when != NULL.

Syllo commented 10 months ago

Thanks