!119 libblkid: (topology) fix read pipe hung and init variables

From: @jiayi0118 
Reviewed-by: @ship_harbour 
Signed-off-by: @ship_harbour
This commit is contained in:
openeuler-ci-bot 2022-11-02 11:51:18 +00:00 committed by Gitee
commit 44bf8b8283
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 93 additions and 1 deletions

View File

@ -0,0 +1,47 @@
From 3f5dd5fa812120764312a2326285e88b2be82c2f Mon Sep 17 00:00:00 2001
From: jiayi0118 <1398871225@qq.com>
Date: Wed, 17 Aug 2022 22:25:27 +0800
Subject: [PATCH] libblkid/src/topology/dm: close redundant write file
description for pipe before reading data.
Reference:https://github.com/util-linux/util-linux/commit/1d5d50c277e459f4ccbb6e3db416dcb6eb2e2bc4
Conflict:NA
---
libblkid/src/topology/dm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libblkid/src/topology/dm.c b/libblkid/src/topology/dm.c
index b210a805b..1a1cb8ac0 100644
--- a/libblkid/src/topology/dm.c
+++ b/libblkid/src/topology/dm.c
@@ -103,6 +103,10 @@ static int probe_dm_tp(blkid_probe pr,
if (!stream)
goto nothing;
+ if (dmpipe[1] != -1) {
+ close(dmpipe[1]);
+ }
+
if (fscanf(stream, "%lld %lld striped %d %d ",
&offset, &size, &stripes, &stripesize) != 0)
goto nothing;
@@ -111,7 +115,6 @@ static int probe_dm_tp(blkid_probe pr,
blkid_topology_set_optimal_io_size(pr, (stripes * stripesize) << 9);
fclose(stream);
- close(dmpipe[1]);
return 0;
nothing:
@@ -119,8 +122,6 @@ nothing:
fclose(stream);
else if (dmpipe[0] != -1)
close(dmpipe[0]);
- if (dmpipe[1] != -1)
- close(dmpipe[1]);
return 1;
}
--
2.31.1

View File

@ -0,0 +1,34 @@
From 819210f37d66949f54fb2f830bc62cb3635a83d5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 19 Aug 2022 11:40:27 +0200
Subject: [PATCH] libblkid: (topology) init variables for DM
Addresses: https://github.com/util-linux/util-linux/issues/1776
Signed-off-by: Karel Zak <kzak@redhat.com>
Reference:https://github.com/util-linux/util-linux/commit/819210f37d66949f54fb2f830bc62cb3635a83d5
Conflict:NA
---
libblkid/src/topology/dm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/topology/dm.c b/libblkid/src/topology/dm.c
index 1a1cb8ac0..77146e2e2 100644
--- a/libblkid/src/topology/dm.c
+++ b/libblkid/src/topology/dm.c
@@ -34,10 +34,10 @@ static int probe_dm_tp(blkid_probe pr,
"/usr/sbin/dmsetup",
"/sbin/dmsetup"
};
- int dmpipe[] = { -1, -1 }, stripes, stripesize;
+ int dmpipe[] = { -1, -1 }, stripes = 0, stripesize = 0;
const char *cmd = NULL;
FILE *stream = NULL;
- long long offset, size;
+ long long offset = 0, size = 0;
size_t i;
dev_t devno = blkid_probe_get_devno(pr);
--
2.31.1

View File

@ -3,7 +3,7 @@
Name: util-linux Name: util-linux
Version: 2.37.2 Version: 2.37.2
Release: 8 Release: 9
Summary: A random collection of Linux utilities Summary: A random collection of Linux utilities
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
@ -37,6 +37,9 @@ Patch6015: backport-mcookie-fix-infinite-loop-when-use-f.patch
Patch6016: backport-sfdisk-write-empty-label-also-when-only-ignored-part.patch Patch6016: backport-sfdisk-write-empty-label-also-when-only-ignored-part.patch
Patch6017: backport-fstat-dir-itself.patch Patch6017: backport-fstat-dir-itself.patch
Patch6018: backport-libblkid-src-topology-dm-close-redundant-write-file-.patch
Patch6019: backport-libblkid-topology-init-variables-for-DM.patch
Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch
Patch9001: SKIPPED-no-root-permissions-test.patch Patch9001: SKIPPED-no-root-permissions-test.patch
@ -404,6 +407,14 @@ fi
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
%changelog %changelog
* Wed Nov 2 2022 January <1398871225@qq.com> - 2.37.2-9
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix fdisk command hung on read pipe when dmsetup command failed and initialize local variables
[add]backport-libblkid-src-topology-dm-close-redundant-write-file-.patch
backport-libblkid-topology-init-variables-for-DM.patch
* Sat Jul 30 2022 zhangyao<zhangyao108@hhuawei.com> - 2.37.2-8 * Sat Jul 30 2022 zhangyao<zhangyao108@hhuawei.com> - 2.37.2-8
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA