57c479
From 6af4962b30c3a8c4c2859898aa862502c6ef1040 Mon Sep 17 00:00:00 2001
57c479
From: Dave Love <dave.love@manchester.ac.uk>
57c479
Date: Sun, 14 May 2017 23:14:35 +0100
57c479
Subject: [PATCH 17/30] Check for read error
57c479
57c479
---
57c479
 src/lib/config_parser.c | 5 +++++
57c479
 1 file changed, 5 insertions(+)
57c479
57c479
diff --git a/src/lib/config_parser.c b/src/lib/config_parser.c
57c479
index e8127abc..b9ef97b6 100644
57c479
--- a/src/lib/config_parser.c
57c479
+++ b/src/lib/config_parser.c
57c479
@@ -77,6 +77,7 @@ char *singularity_config_get_value(char *key) {
57c479
 
57c479
     singularity_message(DEBUG, "Called singularity_config_get_value(%s)\n", key);
57c479
 
57c479
+    errno = 0;
57c479
     while ( fgets(line, MAX_LINE_LEN, config_fp) ) {
57c479
         if ( ( config_key = strtok(line, "=") ) != NULL ) {
57c479
             chomp(config_key);
57c479
@@ -89,6 +90,10 @@ char *singularity_config_get_value(char *key) {
57c479
             }
57c479
         }
57c479
     }
57c479
+    if ( errno != 0 ) {
57c479
+        singularity_message(ERROR, "Reading config file failed: %s\n", strerror(errno));
57c479
+        ABORT(255);
57c479
+    }
57c479
 
57c479
     singularity_message(DEBUG, "No configuration file entry found for '%s'\n", key);
57c479
     return(NULL);
57c479
-- 
57c479
2.11.0
57c479