mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-07 22:21:32 +00:00
When closedir() is called, the directory names are not valid anymore, but read_local_bundles() was returning a list of them. The related valgrind message ==20540== Invalid read of size 1 ==20540== at 0x48353E8: mempcpy (vg_replace_strmem.c:1524) ==20540== by 0x50F0E30: _IO_file_xsputn (in /usr/lib64/haswell/libc-2.26.so) ==20540== by 0x50E5CAE: puts (in /usr/lib64/haswell/libc-2.26.so) ==20540== by 0x408187: printf (stdio2.h:104) ==20540== by 0x408187: bundle_list_main (clr_bundle_ls.c:232) ==20540== by 0x508CF69: (below main) (in /usr/lib64/haswell/libc-2.26.so) ==20540== Address 0x58a70fb is 859 bytes inside a block of size 32,816 free'd ==20540== at 0x482CD0B: free (vg_replace_malloc.c:530) ==20540== by 0x51481CC: closedir (in /usr/lib64/haswell/libc-2.26.so) ==20540== by 0x484F4E3: read_local_bundles (bundle.c:937) ==20540== by 0x408154: bundle_list_main (clr_bundle_ls.c:225) ==20540== by 0x508CF69: (below main) (in /usr/lib64/haswell/libc-2.26.so) ==20540== Block was alloc'd at ==20540== at 0x482BADF: malloc (vg_replace_malloc.c:299) ==20540== by 0x5147F2D: ??? (in /usr/lib64/haswell/libc-2.26.so) ==20540== by 0x484F486: read_local_bundles (bundle.c:926) ==20540== by 0x408154: bundle_list_main (clr_bundle_ls.c:225) ==20540== by 0x508CF69: (below main) (in /usr/lib64/haswell/libc-2.26.so) Instead of duplicating the strings to return, just renamed it to list_local_bundles() and sorted / printed before closedir() call. This makes that code similar to the other listing functions.