Bug 43956 - sgdisk --version segfault
Summary: sgdisk --version segfault
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: gdisk (show other bugs)
Version: unstable
Hardware: all Linux
: P5 normal
Assignee: Alexey Shabalin
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-05 16:57 MSK by Ivan A. Melnikov
Modified: 2022-10-05 18:41 MSK (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan A. Melnikov 2022-10-05 16:57:05 MSK
# sgdisk --version
GPT fdisk (sgdisk) version 1.0.9.1

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-1.0.9.1-alt1 -> sisyphus:

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

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

0