diff -Nru lsvpd-1.7.6/debian/changelog lsvpd-1.7.6/debian/changelog --- lsvpd-1.7.6/debian/changelog 2016-04-12 12:27:05.000000000 +0000 +++ lsvpd-1.7.6/debian/changelog 2017-08-22 10:58:20.000000000 +0000 @@ -1,3 +1,10 @@ +lsvpd (1.7.6-0ubuntu4) xenial-proposed; urgency=medium + + * SRU: LP: #1705582 + * Unique name for temp Device file given and file closed before deleting it. + + -- Matthias Klose Tue, 22 Aug 2017 12:55:39 +0200 + lsvpd (1.7.6-0ubuntu3) xenial; urgency=medium * No-change rebuild for librtas2 soname change. diff -Nru lsvpd-1.7.6/debian/patches/0001-Unique-name-for-temp-Device-file-given-and-file-clos.patch lsvpd-1.7.6/debian/patches/0001-Unique-name-for-temp-Device-file-given-and-file-clos.patch --- lsvpd-1.7.6/debian/patches/0001-Unique-name-for-temp-Device-file-given-and-file-clos.patch 1970-01-01 00:00:00.000000000 +0000 +++ lsvpd-1.7.6/debian/patches/0001-Unique-name-for-temp-Device-file-given-and-file-clos.patch 2017-07-20 22:09:26.000000000 +0000 @@ -0,0 +1,136 @@ +From 8f9a2c4395bc8d974ef8fd5d2f0bb0fd92b043f8 Mon Sep 17 00:00:00 2001 +From: Ankit Kumar +Date: Thu, 20 Jul 2017 17:20:03 +0530 +Subject: [PATCH] Unique name for temp Device file given and file closed before + deleting it. + +lsvpd: Unique name for temp Device file given and file closed before deleting it. + +This piece of code used mkstemp to get unique name of file in that particular +directory. As file name is not hardcoded, so parameter for device_close and +device_open is changed to pass device location path. + +This patch also fixes the issue of opened file which is not closed by closing +file descriptor. + +Signed-off-by: Ankit Kumar +[Removed redundant variable - Vasant] +Signed-off-by: Vasant Hegde +--- + src/internal/sys_interface/sysfs_SCSI_Fill.cpp | 54 ++++++++++++++------------ + 1 file changed, 30 insertions(+), 24 deletions(-) + +diff --git a/src/internal/sys_interface/sysfs_SCSI_Fill.cpp b/src/internal/sys_interface/sysfs_SCSI_Fill.cpp +index 836d6cc..1a31822 100644 +--- a/src/internal/sys_interface/sysfs_SCSI_Fill.cpp ++++ b/src/internal/sys_interface/sysfs_SCSI_Fill.cpp +@@ -67,6 +67,7 @@ + #include + #include + #include ++#include + + extern "C" + { +@@ -840,43 +841,49 @@ namespace lsvpd + /** + * Close a device that may have been opened for reading + */ +- void device_close(int device_fd, int major, int minor, int mode) ++ void device_close(int device_fd, string& dev_path) + { +- char name[256]; + struct stat statbuf; +- if (-1 != sprintf(name, "/tmp/node-%d-%d-%d", +- mode, major, minor)) { +- if (stat(name, &statbuf) == 0) { +- unlink(name); +- } +- } + ++ if (stat(dev_path.c_str(), &statbuf) == 0) { ++ if(device_fd >= 0) ++ close(device_fd); ++ unlink(dev_path.c_str()); ++ } + } + + // Open a temp file through which we can ioctl() to device for reading +- int device_open(int major, int minor, int mode) ++ int device_open(int major, int minor, int mode, string& dev_path) + { +- char name[256]; ++ char name[PATH_MAX]; ++ /* Var is used to store unique name */ ++ char template_d[] = "/tmp/node-XXXXXX"; + int device_fd = 0; + int ret; + struct stat statbuf; + +- if (sprintf(name, "/tmp/node-%d-%d-%d", mode, major, minor) < 0) { +- return -ERROR_ACCESSING_DEVICE; +- } ++ device_fd = mkstemp(template_d); ++ if (device_fd == -1) ++ return -1; ++ close(device_fd); + +- if (stat(name, &statbuf) == 0) { +- unlink(name); +- } ++ if (stat(template_d, &statbuf) == 0) ++ unlink(template_d); ++ ++ if (snprintf(name, PATH_MAX - 1, "%s-%d-%d-%d", ++ template_d, mode, major, minor) < 0) ++ return -ERROR_ACCESSING_DEVICE; + + ret = mknod(name, 0760 | mode, makedev(major, minor)); +- if (ret != 0){ ++ if (ret != 0) + return -UNABLE_TO_MKNOD_FILE; +- } ++ ++ /* Store temp device filename. It will be used in device_close */ ++ dev_path = string(name); + + device_fd = open(name, 0); + if (device_fd < 0) { +- device_close(device_fd, major, minor, mode); ++ device_close(device_fd, dev_path); + return -UNABLE_TO_OPEN_FILE; + } + +@@ -1488,6 +1495,7 @@ out: + ostringstream err; + Logger logger; + string msg; ++ string dev_path; + /* Not a SCSI device */ + if (fillMe->devBus.getValue() == "usb") + return; +@@ -1501,7 +1509,8 @@ out: + // Open Device for reading + device_fd = device_open(fillMe->devMajor, + fillMe->devMinor, +- fillMe->devAccessMode); ++ fillMe->devAccessMode, ++ dev_path); + if (device_fd < 0) { + msg = string("vpdupdate: Failed opening device: ") + + fillMe->idNode.getValue(); +@@ -1511,10 +1520,7 @@ out: + + collectVpd(fillMe, device_fd, limitSCSISize); + +- device_close(device_fd, +- fillMe->devMajor, +- fillMe->devMinor, +- fillMe->devAccessMode); ++ device_close(device_fd, dev_path); + } + + fillIPRData( fillMe ); +-- +2.7.4 + diff -Nru lsvpd-1.7.6/debian/patches/series lsvpd-1.7.6/debian/patches/series --- lsvpd-1.7.6/debian/patches/series 2016-01-14 15:21:06.000000000 +0000 +++ lsvpd-1.7.6/debian/patches/series 2017-08-22 10:57:11.000000000 +0000 @@ -0,0 +1 @@ +0001-Unique-name-for-temp-Device-file-given-and-file-clos.patch