diff mbox

[libibverbs,v2,02/11] read_config(): ignore directory entry with backup suffix (~)

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

Commit Message

Yann Droneaud Aug. 8, 2013, 7:40 p.m. UTC
Files ending with a tilde '~' are likely backup files
so they should not be considered as valid configuration files.

This patch makes read_config() skip backup files in order
to protect libibverbs from using 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 ce9e1c0..e67469e 100644
--- a/src/init.c
+++ b/src/init.c
@@ -309,6 +309,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);