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

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