Skip to contentSkip to conversation

cifscreds: check optind before accessing argv[optind]

PATCH In review Ronnie Sahlberg 2 participants 3 messages Jan 23, 2018 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifscreds: check optind before accessing argv[optind]

Redhat bugzilla: 1278543

This fixes a segfault for some incorrect usage, for example
cifscreds -u test

---
 cifscreds.c | 3 +++
 1 file changed, 3 insertions(+)
cifscreds.c +3 -0
index 5d84c3c..32f2ee4 100644
@@ -487,6 +487,9 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (optind >= argc)
+		return usage();
+
 	/* find the best fit command */
 	best = NULL;
 	n = strnlen(argv[optind], MAX_COMMAND_SIZE);
Signature · 1 line
2.15.1

A message that is not in the archive (sent off-list or not yet received): CAH2r5ms-rpxf5E_XZc1W+h1tMmV26WEbXWCxEfYa+cA7PX-VTw@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAH2r5ms-rpxf5E_XZc1W+h1tMmV26WEbXWCxEfYa+cA7PX-VTw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#3 lore raw

----- Original Message -----

Quoted 7 lines

From: "Steve French" <[email protected]>
To: "Ronnie Sahlberg" <[email protected]>
Cc: "CIFS" <[email protected]>, "Pavel Shilovsky" <[email protected]>
Sent: Tuesday, 23 January, 2018 11:50:38 AM
Subject: Re: [PATCH] cifscreds: check optind before accessing argv[optind]

I would like to add cc stable. Ok?

SGTM

Quoted 36 lines · Ronnie Sahlberg
Quoted 33 lines

Redhat bugzilla: 1278543

This fixes a segfault for some incorrect usage, for example
cifscreds -u test

---
 cifscreds.c | 3 +++
 1 file changed, 3 insertions(+)
cifscreds.c +3 -1
index 5d84c3c..32f2ee4 100644
@@ -487,6 +487,9 @@ int main(int argc, char **argv)
                }
        }
 
+       if (optind >= argc)
+               return usage();
+
        /* find the best fit command */
        best = NULL;
        n = strnlen(argv[optind], MAX_COMMAND_SIZE);
--

2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1836982403.1740018.1516669060551.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#5 lore raw

sorry - I misread this. Userspace patch doersn't need the cc:

but in any case can add my reviewed-by

Quoted 51 lines · Ronnie Sahlberg

----- Original Message -----

Quoted 7 lines

From: "Steve French" <[email protected]>
To: "Ronnie Sahlberg" <[email protected]>
Cc: "CIFS" <[email protected]>, "Pavel Shilovsky" <[email protected]>
Sent: Tuesday, 23 January, 2018 11:50:38 AM
Subject: Re: [PATCH] cifscreds: check optind before accessing argv[optind]

I would like to add cc stable. Ok?

SGTM

Quoted 36 lines · Ronnie Sahlberg
Quoted 33 lines

Redhat bugzilla: 1278543

This fixes a segfault for some incorrect usage, for example
cifscreds -u test

---
 cifscreds.c | 3 +++
 1 file changed, 3 insertions(+)
cifscreds.c +3 -1
index 5d84c3c..32f2ee4 100644
@@ -487,6 +487,9 @@ int main(int argc, char **argv)
                }
        }
 
+       if (optind >= argc)
+               return usage();
+
        /* find the best fit command */
        best = NULL;
        n = strnlen(argv[optind], MAX_COMMAND_SIZE);
--

2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Thanks,

Steve