main/smartmontools: fix segfault

fixes: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15948
ref: https://www.smartmontools.org/ticket/1830
This commit is contained in:
Natanael Copa 2024-05-08 11:08:03 +02:00
parent 36e202fe9f
commit ce823f38fa
2 changed files with 18 additions and 2 deletions

View file

@ -1,14 +1,15 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=smartmontools
pkgver=7.4
pkgrel=0
pkgrel=1
pkgdesc="Control and monitor S.M.A.R.T. enabled hard drives"
url="https://www.smartmontools.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers"
subpackages="$pkgname-doc $pkgname-openrc"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-openrc"
source="https://downloads.sourceforge.net/sourceforge/smartmontools/smartmontools-$pkgver.tar.gz
fix-segfault-in-option-handling.patch
smartd.initd
smartd.confd
"
@ -39,6 +40,7 @@ package() {
sha512sums="
439fbf8d0e77fbe1d5a9fb100e655a7e47a82382ce8e1a4e942541a4dfbdff3391caa635e8d354d0e87c10ae79cb97aa6d24915f9f193620d763b384baf2e753 smartmontools-7.4.tar.gz
d41ba269b46591e605a87e043acd77fd2de3a723405fc83de0848afa8592f1ad912c5ac1e8199b10008ea53d8cfbc4917bf037578e7242346945664caa5bfc48 fix-segfault-in-option-handling.patch
4a2cbdab37cf0d761924854be4a2f2deebed22ca8d8754dee9a5ec44229c608f5fffb19545d2b9c687ab010460acde51d4f5fccd74d6c80dab2b1a7401d59b9f smartd.initd
9088b97fbaac45e677e5ac14bc8a9edb4bd7a924717bb201db92f4a85447bb0e0254e716c8c8e60d4830b96e3221488fc80b30442b2e4a1b57741535aa2c3e7b smartd.confd
"

View file

@ -0,0 +1,14 @@
upstream: https://www.smartmontools.org/ticket/1830#comment:1
diff --git a/smartctl.cpp b/smartctl.cpp
index da97640..41a6e0a 100644
--- a/smartctl.cpp
+++ b/smartctl.cpp
@@ -1168,7 +1168,7 @@ static int parse_options(int argc, char** argv, const char * & type,
printing_is_off = false;
printslogan();
// Point arg to the argument in which this option was found.
- arg = argv[optind-1];
+ arg = argv[optind-2];
// Check whether the option is a long option that doesn't map to -h.
if (arg[1] == '-' && optchar != 'h') {
// Iff optopt holds a valid option then argument must be missing.