Blame SOURCES/hypervkvpd-0-long_file_names_from_readdir.patch
|
|
7b0ce3 |
diff --git a/hv_kvp_daemon.c b/hv_kvp_daemon.c
|
|
|
68a822 |
old mode 100644
|
|
|
68a822 |
new mode 100755
|
|
|
68a822 |
index 408bb07..c106498
|
|
|
7b0ce3 |
--- a/hv_kvp_daemon.c
|
|
|
7b0ce3 |
+++ b/hv_kvp_daemon.c
|
|
|
7b0ce3 |
@@ -44,6 +44,7 @@
|
|
|
7b0ce3 |
#include <dirent.h>
|
|
|
7b0ce3 |
#include <net/if.h>
|
|
|
68a822 |
#include <getopt.h>
|
|
|
7b0ce3 |
+#include <limits.h>
|
|
|
7b0ce3 |
|
|
|
7b0ce3 |
/*
|
|
|
7b0ce3 |
* KVP protocol: The user mode component first registers with the
|
|
|
68a822 |
@@ -601,26 +602,22 @@ static char *kvp_get_if_name(char *guid)
|
|
|
7b0ce3 |
DIR *dir;
|
|
|
7b0ce3 |
struct dirent *entry;
|
|
|
7b0ce3 |
FILE *file;
|
|
|
7b0ce3 |
- char *p, *q, *x;
|
|
|
7b0ce3 |
+ char *p, *x;
|
|
|
7b0ce3 |
char *if_name = NULL;
|
|
|
7b0ce3 |
char buf[256];
|
|
|
7b0ce3 |
char *kvp_net_dir = "/sys/class/net/";
|
|
|
7b0ce3 |
- char dev_id[256];
|
|
|
7b0ce3 |
+ char dev_id[PATH_MAX];
|
|
|
7b0ce3 |
|
|
|
7b0ce3 |
dir = opendir(kvp_net_dir);
|
|
|
7b0ce3 |
if (dir == NULL)
|
|
|
7b0ce3 |
return NULL;
|
|
|
7b0ce3 |
|
|
|
7b0ce3 |
- snprintf(dev_id, sizeof(dev_id), "%s", kvp_net_dir);
|
|
|
7b0ce3 |
- q = dev_id + strlen(kvp_net_dir);
|
|
|
7b0ce3 |
-
|
|
|
7b0ce3 |
while ((entry = readdir(dir)) != NULL) {
|
|
|
7b0ce3 |
/*
|
|
|
7b0ce3 |
* Set the state for the next pass.
|
|
|
7b0ce3 |
*/
|
|
|
7b0ce3 |
- *q = '\0';
|
|
|
7b0ce3 |
- strcat(dev_id, entry->d_name);
|
|
|
7b0ce3 |
- strcat(dev_id, "/device/device_id");
|
|
|
7b0ce3 |
+ snprintf(dev_id, sizeof(dev_id), "%s%s/device/device_id", kvp_net_dir,
|
|
|
7b0ce3 |
+ entry->d_name);
|
|
|
7b0ce3 |
|
|
|
7b0ce3 |
file = fopen(dev_id, "r");
|
|
|
7b0ce3 |
if (file == NULL)
|