1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Fix _get_proc_number to be tolerant of malformed /proc/misc entries.

Fixes issue reported here: http://lkml.org/lkml/2011/11/8/190
This commit is contained in:
Mike Snitzer 2011-11-08 17:32:10 +00:00
parent 6b58c79603
commit 52f3043f15
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.68 - Version 1.02.68 -
================================== ==================================
Fix _get_proc_number to be tolerant of malformed /proc/misc entries.
Add ExecReload to dm-event.service for systemd to reload dmeventd properly. Add ExecReload to dm-event.service for systemd to reload dmeventd properly.
Add dm_config_tree_find_str_allow_empty. Add dm_config_tree_find_str_allow_empty.
Fix compile-time pool memory locking with DEBUG_MEM. Fix compile-time pool memory locking with DEBUG_MEM.

View File

@ -172,7 +172,8 @@ static int _get_proc_number(const char *file, const char *name,
{ {
FILE *fl; FILE *fl;
char nm[256]; char nm[256];
int c; char *line;
size_t len;
uint32_t num; uint32_t num;
if (!(fl = fopen(file, "r"))) { if (!(fl = fopen(file, "r"))) {
@ -180,8 +181,8 @@ static int _get_proc_number(const char *file, const char *name,
return 0; return 0;
} }
while (!feof(fl)) { while (getline(&line, &len, fl) != -1) {
if (fscanf(fl, "%d %255s\n", &num, &nm[0]) == 2) { if (sscanf(line, "%d %255s\n", &num, &nm[0]) == 2) {
if (!strcmp(name, nm)) { if (!strcmp(name, nm)) {
if (number) { if (number) {
*number = num; *number = num;
@ -191,9 +192,7 @@ static int _get_proc_number(const char *file, const char *name,
} }
dm_bit_set(_dm_bitset, num); dm_bit_set(_dm_bitset, num);
} }
} else do { }
c = fgetc(fl);
} while (c != EOF && c != '\n');
} }
if (fclose(fl)) if (fclose(fl))
log_sys_error("fclose", file); log_sys_error("fclose", file);