Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
mdadm.5365
0230-Increase-buffer-for-sysfs-path.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0230-Increase-buffer-for-sysfs-path.patch of Package mdadm.5365
From bbb52f2b1dd049a15323d7bccde50e5818abd175 Mon Sep 17 00:00:00 2001 From: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Date: Fri, 28 Oct 2016 10:35:50 +0200 Subject: [PATCH 327/359] Increase buffer for sysfs path References: bsc#1081910 'unacknowledged_bad_blocks' is a long name for sysfs property and it makes sysfs path over 50 characters long. Increase buffer to the double length of the longest path available in sysfs at the moment. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Coly Li <colyli@suse.de> --- sysfs.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) Index: mdadm-3.3.1/sysfs.c =================================================================== --- mdadm-3.3.1.orig/sysfs.c +++ mdadm-3.3.1/sysfs.c @@ -27,6 +27,8 @@ #include <dirent.h> #include <ctype.h> +#define MAX_SYSFS_PATH_LEN 120 + int load_sys(char *path, char *buf, int len) { int fd = open(path, O_RDONLY); @@ -59,15 +61,15 @@ void sysfs_free(struct mdinfo *sra) int sysfs_open(char *devnm, char *devname, char *attr) { - char fname[50]; + char fname[MAX_SYSFS_PATH_LEN]; int fd; - sprintf(fname, "/sys/block/%s/md/", devnm); + snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/", devnm); if (devname) { - strcat(fname, devname); - strcat(fname, "/"); + strncat(fname, devname, MAX_SYSFS_PATH_LEN - strlen(fname)); + strncat(fname, "/", MAX_SYSFS_PATH_LEN - strlen(fname)); } - strcat(fname, attr); + strncat(fname, attr, MAX_SYSFS_PATH_LEN - strlen(fname)); fd = open(fname, O_RDWR); if (fd < 0 && errno == EACCES) fd = open(fname, O_RDONLY); @@ -392,14 +394,16 @@ unsigned long long get_component_size(in * This returns in units of sectors. */ struct stat stb; - char fname[50]; + char fname[MAX_SYSFS_PATH_LEN]; int n; if (fstat(fd, &stb)) return 0; if (major(stb.st_rdev) != (unsigned)get_mdp_major()) - sprintf(fname, "/sys/block/md%d/md/component_size", + snprintf(fname, MAX_SYSFS_PATH_LEN, + "/sys/block/md%d/md/component_size", (int)minor(stb.st_rdev)); else - sprintf(fname, "/sys/block/md_d%d/md/component_size", + snprintf(fname, MAX_SYSFS_PATH_LEN, + "/sys/block/md_d%d/md/component_size", (int)minor(stb.st_rdev)>>MdpMinorShift); fd = open(fname, O_RDONLY); if (fd < 0) @@ -415,11 +419,11 @@ unsigned long long get_component_size(in int sysfs_set_str(struct mdinfo *sra, struct mdinfo *dev, char *name, char *val) { - char fname[50]; + char fname[MAX_SYSFS_PATH_LEN]; unsigned int n; int fd; - sprintf(fname, "/sys/block/%s/md/%s/%s", + snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/%s/%s", sra->sys_name, dev?dev->sys_name:"", name); fd = open(fname, O_WRONLY); if (fd < 0) @@ -452,11 +456,11 @@ int sysfs_set_num_signed(struct mdinfo * int sysfs_uevent(struct mdinfo *sra, char *event) { - char fname[50]; + char fname[MAX_SYSFS_PATH_LEN]; int n; int fd; - sprintf(fname, "/sys/block/%s/uevent", + snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/uevent", sra->sys_name); fd = open(fname, O_WRONLY); if (fd < 0) @@ -473,10 +477,10 @@ int sysfs_uevent(struct mdinfo *sra, cha int sysfs_attribute_available(struct mdinfo *sra, struct mdinfo *dev, char *name) { - char fname[50]; + char fname[MAX_SYSFS_PATH_LEN]; struct stat st; - sprintf(fname, "/sys/block/%s/md/%s/%s", + snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/%s/%s", sra->sys_name, dev?dev->sys_name:"", name); return stat(fname, &st) == 0; @@ -485,10 +489,10 @@ int sysfs_attribute_available(struct mdi int sysfs_get_fd(struct mdinfo *sra, struct mdinfo *dev, char *name) { - char fname[50]; + char fname[MAX_SYSFS_PATH_LEN]; int fd; - sprintf(fname, "/sys/block/%s/md/%s/%s", + snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/%s/%s", sra->sys_name, dev?dev->sys_name:"", name); fd = open(fname, O_RDWR); if (fd < 0)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor