From 2e68bf758369b2b593265cd96aca189b82b9b432 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 25 Feb 2023 18:51:23 +0100 Subject: Refreshing exit-gracefully-when-md-device-not-found.patch. Signed-off-by: Daniel Baumann --- ...-exit-gracefully-when-md-device-not-found.patch | 23 ++++++++++++++++++++ .../exit-gracefully-when-md-device-not-found.patch | 25 ---------------------- debian/patches/series | 2 +- 3 files changed, 24 insertions(+), 26 deletions(-) create mode 100644 debian/patches/debian/0004-exit-gracefully-when-md-device-not-found.patch delete mode 100644 debian/patches/exit-gracefully-when-md-device-not-found.patch diff --git a/debian/patches/debian/0004-exit-gracefully-when-md-device-not-found.patch b/debian/patches/debian/0004-exit-gracefully-when-md-device-not-found.patch new file mode 100644 index 0000000..c580449 --- /dev/null +++ b/debian/patches/debian/0004-exit-gracefully-when-md-device-not-found.patch @@ -0,0 +1,23 @@ +Author: Felix Lechner +Description: Exit gracefully when md device not found (Closes: #970329). + +diff -Naurp mdadm.orig/Monitor.c mdadm/Monitor.c +--- mdadm.orig/Monitor.c ++++ mdadm/Monitor.c +@@ -554,8 +554,14 @@ static int check_array(struct state *st, + if (fd < 0) + goto disappeared; + +- if (st->devnm[0] == 0) +- snprintf(st->devnm, MD_NAME_MAX, "%s", fd2devnm(fd)); ++ if (st->devnm[0] == 0) { ++ char *found = fd2devnm(fd); ++ if (!found) { ++ alert("DeviceDisappeared", dev, NULL, ainfo); ++ goto out; ++ } ++ snprintf(st->devnm, MD_NAME_MAX, "%s", found); ++ } + + for (mse2 = mdstat; mse2; mse2 = mse2->next) + if (strcmp(mse2->devnm, st->devnm) == 0) { diff --git a/debian/patches/exit-gracefully-when-md-device-not-found.patch b/debian/patches/exit-gracefully-when-md-device-not-found.patch deleted file mode 100644 index c6a34d5..0000000 --- a/debian/patches/exit-gracefully-when-md-device-not-found.patch +++ /dev/null @@ -1,25 +0,0 @@ -Description: Exit gracefully when md device not found -Author: Felix Lechner -Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=970329 -Forwarded: no ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/Monitor.c -+++ b/Monitor.c -@@ -539,8 +539,14 @@ static int check_array(struct state *st, - if (fd < 0) - goto disappeared; - -- if (st->devnm[0] == 0) -- strcpy(st->devnm, fd2devnm(fd)); -+ if (st->devnm[0] == 0) { -+ char *found = fd2devnm(fd); -+ if (!found) { -+ alert("DeviceDisappeared", dev, NULL, ainfo); -+ goto out; -+ } -+ strcpy(st->devnm, found); -+ } - - for (mse2 = mdstat; mse2; mse2 = mse2->next) - if (strcmp(mse2->devnm, st->devnm) == 0) { diff --git a/debian/patches/series b/debian/patches/series index f779685..d368285 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,7 +1,7 @@ debian/0001-fix-manpages.patch debian/0002-mdmonitor-service-simplify.patch debian/0003-host-name-in-default-mailfrom.patch -exit-gracefully-when-md-device-not-found.patch +debian/0004-exit-gracefully-when-md-device-not-found.patch sha1-includes.diff readlink-path.patch debian-no-Werror.diff -- cgit v1.2.3