Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri,  9 Jun 2017 00:26:18 -0500
From: "A. Wilcox" <awilfox@...lielinux.org>
To: musl@...ts.openwall.com
Cc: "A. Wilcox" <AWilcox@...cox-Tech.com>
Subject: [PATCH 3/3] getdate: correctly specify error number

From: "A. Wilcox" <AWilcox@...cox-Tech.com>

POSIX defines getdate error #5 as:
"An I/O error is encountered while reading the template file."

POSIX defines getdate error #7 as:
"There is no line in the template that matches the input."

This change correctly disambiguates between the two error conditions.
---
 src/time/getdate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/time/getdate.c b/src/time/getdate.c
index 89f2169..420cd8e 100644
--- a/src/time/getdate.c
+++ b/src/time/getdate.c
@@ -37,7 +37,8 @@ struct tm *getdate(const char *s)
 		}
 	}
 
-	getdate_err = 7;
+	if (ferror(f)) getdate_err = 5;
+	else getdate_err = 7;
 out:
 	if (f) fclose(f);
 	pthread_setcancelstate(cs, 0);
-- 
2.10.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.