diff mbox

[2/3] read_config: ignore directory entry with backup suffix (~)

Message ID efd912bd0a555c60c10a2160318f8048fdcd60b4.1369085762.git.ydroneaud@opteya.com (mailing list archive)
State Rejected
Headers show

Commit Message

Yann Droneaud May 20, 2013, 9:43 p.m. UTC
Try to protect libibverbs from hand modified configuration files.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 src/init.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/src/init.c b/src/init.c
index c880b68..1981da7 100644
--- a/src/init.c
+++ b/src/init.c
@@ -311,6 +311,9 @@  static void read_config(void)
 		if (dent->d_name[0] == '.')
 			continue;
 
+		if (dent->d_name[0] == '\0' || dent->d_name[strlen(dent->d_name) - 1] == '~')
+			continue;
+
 		if (asprintf(&path, "%s/%s", IBV_CONFIG_DIR, dent->d_name) < 0) {
 			fprintf(stderr, PFX "Warning: couldn't read config file %s/%s.\n",
 				IBV_CONFIG_DIR, dent->d_name);