Blame SOURCES/autofs-5.1.8-fix-minus-only-option-handling-in-concat_options.patch

288172
autofs-5.1.8 - fix minus only option handling in concat_options()
288172
288172
From: Ian Kent <raven@themaw.net>
288172
288172
While a '-' alone isn't strictly valid it hadn't previously cuased a
288172
parse error. So commit 9047e91ffa69 (autofs-5.1.7 - fix concat_options()
288172
error handling) introduced a regression by no longer allowing this.
288172
288172
Fix this regression by only failing if errno is set to a non-zero value
288172
on return from concat_options() as well as returning NULL.
288172
288172
Fixes: 9047e91ffa69 (autofs-5.1.7 - fix concat_options() error handling)
288172
Signed-off-by: Ian Kent <raven@themaw.net>
288172
---
288172
 CHANGELOG           |    1 +
288172
 modules/parse_sun.c |   25 +++++++++++++++++++------
288172
 2 files changed, 20 insertions(+), 6 deletions(-)
288172
288172
--- autofs-5.1.4.orig/CHANGELOG
288172
+++ autofs-5.1.4/CHANGELOG
288172
@@ -103,6 +103,7 @@
288172
 - fix deadlock with hosts map reload.
288172
 - fix memory leak in update_hosts_mounts().
288172
 - fix concat_options() error handling.
288172
+- fix minus only option handling in concat_options().
288172
 
288172
 xx/xx/2018 autofs-5.1.5
288172
 - fix flag file permission.
288172
--- autofs-5.1.4.orig/modules/parse_sun.c
288172
+++ autofs-5.1.4/modules/parse_sun.c
288172
@@ -376,10 +376,16 @@ static int do_init(int argc, const char
288172
 	if (gbl_options) {
288172
 		append_options = defaults_get_append_options();
288172
 		if (append_options) {
288172
-			char *tmp = concat_options(gbl_options, ctxt->optstr);
288172
+			char *tmp;
288172
+
288172
+			errno = 0;
288172
+			tmp = concat_options(gbl_options, ctxt->optstr);
288172
 			if (!tmp) {
288172
-				char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
288172
-				logerr(MODPREFIX "concat_options: %s", estr);
288172
+				/* Ignore non-error NULL return */
288172
+				if (errno) {
288172
+					char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
288172
+					logerr(MODPREFIX "concat_options: %s", estr);
288172
+				}
288172
 				/* freed in concat_options */
288172
 				ctxt->optstr = NULL;
288172
 			} else
288172
@@ -996,9 +1002,12 @@ static int parse_mapent(const char *ent,
288172
 				free(myoptions);
288172
 				myoptions = newopt;
288172
 			} else if (newopt) {
288172
+				errno = 0;
288172
 				tmp = concat_options(myoptions, newopt);
288172
-				if (!tmp) {
288172
+				/* Ignore non-error NULL return */
288172
+				if (!tmp && errno) {
288172
 					char *estr;
288172
+
288172
 					estr = strerror_r(errno, buf, MAX_ERR_BUF);
288172
 					error(logopt, MODPREFIX
288172
 					      "concat_options: %s", estr);
288172
@@ -1370,8 +1379,10 @@ dont_expand:
288172
 				free(mnt_options);
288172
 				mnt_options = noptions;
288172
 			} else if (noptions) {
288172
+				errno = 0;
288172
 				tmp = concat_options(mnt_options, noptions);
288172
-				if (!tmp) {
288172
+				/* Ignore non-error NULL return */
288172
+				if (!tmp && errno) {
288172
 					char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
288172
 					error(ap->logopt,
288172
 					      MODPREFIX "concat_options: %s", estr);
288172
@@ -1395,8 +1406,10 @@ dont_expand:
288172
 				free(options);
288172
 				options = mnt_options;
288172
 			} else if (mnt_options) {
288172
+				errno = 0;
288172
 				tmp = concat_options(options, mnt_options);
288172
-				if (!tmp) {
288172
+				/* Ignore non-error NULL return */
288172
+				if (!tmp && errno) {
288172
 					char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
288172
 					error(ap->logopt, MODPREFIX "concat_options: %s", estr);
288172
 					free(pmapent);