Bug 43956

Summary: sgdisk --version segfault
Product: Sisyphus Reporter: Ivan A. Melnikov <iv>
Component: gdiskAssignee: Alexey Shabalin <shaba>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P5 CC: shaba
Version: unstable   
Hardware: all   
OS: Linux   

Description Ivan A. Melnikov 2022-10-05 16:57:05 MSK
# sgdisk --version
GPT fdisk (sgdisk) version

Segmentation fault (core dumped)

Reproduces every time on my machine (x86_64, Sisyphus) and on hifive unmatched (sisyphus_riscv64).
Comment 1 Ivan A. Melnikov 2022-10-05 16:59:12 MSK
Backtrace on x86_64 with debug symbols installed:

  #0  0x00007ffff7980a19 in __strlen_avx2 () from /lib64/libc.so.6
  #1  0x00007ffff789f9bf in __GI___strdup (s=0x0) at strdup.c:41
  #2  0x0000555555559292 in GPTDataCL::DoOptions (argv=<optimized out>, argc=<optimized out>, this=0x7fffffffc5c0) at /usr/src/debug/gptfdisk-1.0.9/gptcl.cc:158
  #3  main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/gptfdisk-1.0.9/sgdisk.cc:20

Line 158 of gptcl.cc indeed calls strdup, which does not accept NULLs as first argument.
Comment 2 Repository Robot 2022-10-05 18:39:15 MSK
gptfdisk- -> sisyphus:

 Wed Oct 05 2022 Alexey Shabalin <shaba@altlinux>
 - Fix NULL dereference when duplicating string argument (ALT#43956)
Comment 3 Alexey Shabalin 2022-10-05 18:41:21 MSK
Исправлено в gdisk-

$ /usr/sbin/sgdisk --version; echo $?
GPT fdisk (sgdisk) version