diff mbox series

[v2,01/13] btrfs-progs: send: fix crash on unknown option

Message ID e0aff7fddf35f0f18ff21d1e2e50a5d127254392.1605723745.git.osandov@osandov.com (mailing list archive)
State New, archived
Headers show
Series [v2,01/13] btrfs-progs: send: fix crash on unknown option | expand

Commit Message

Omar Sandoval Nov. 18, 2020, 7:18 p.m. UTC
From: Omar Sandoval <osandov@fb.com>

The long options array for send is missing the zero terminator, so
unknown options result in a crash:

  # btrfs send --foo
  Segmentation fault (core dumped)

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 cmds/send.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Sterba Dec. 16, 2020, 4:20 p.m. UTC | #1
On Wed, Nov 18, 2020 at 11:18:44AM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> The long options array for send is missing the zero terminator, so
> unknown options result in a crash:
> 
>   # btrfs send --foo
>   Segmentation fault (core dumped)
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>

As this is an independent bugfix, I'll add it to devel now, thanks.
diff mbox series

Patch

diff --git a/cmds/send.c b/cmds/send.c
index b8e3ba12..3bfc69f5 100644
--- a/cmds/send.c
+++ b/cmds/send.c
@@ -496,7 +496,8 @@  static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
 		static const struct option long_options[] = {
 			{ "verbose", no_argument, NULL, 'v' },
 			{ "quiet", no_argument, NULL, 'q' },
-			{ "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA }
+			{ "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA },
+			{ NULL, 0, NULL, 0 }
 		};
 		int c = getopt_long(argc, argv, "vqec:f:i:p:", long_options, NULL);