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