Date: Tue, 7 Apr 2009 20:45:22 GMT From: Rafal Grodzinski <grodzix@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/133473: [patch] pkg_info throws segmentation fault if given non-existent long option Message-ID: <200904072045.n37KjMxj013258@www.freebsd.org> Resent-Message-ID: <200904072050.n37Ko5h4041651@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 133473
>Category: bin
>Synopsis: [patch] pkg_info throws segmentation fault if given non-existent long option
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Apr 07 20:50:05 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Rafal Grodzinski
>Release: 7.1-Release
>Organization:
>Environment:
FreeBSD grodzix 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 14:37:25 UTC 2009 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>Description:
pkg_info (usr.sbin/pkg_install/info) throws segmentation fault if non existent long option is provided.
Array struct option longopts[] in main.c isn't ended with {NULL, 0, NULL, 0} so getopt_long doesn't know where to stop and tries to read past the last element of the array.
>How-To-Repeat:
pkg_info --y
pkg_info --ble
>Fix:
Add {NULL, 0, NULL, 0} at the end of struct option longopts[] array in main.c
Patch attached with submission follows:
--- /usr/src/usr.sbin/pkg_install/info/main.c 2008-11-25 02:59:29.000000000 +0000
+++ main.c 2009-04-07 20:01:57.000000000 +0000
@@ -58,6 +58,7 @@
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'P' },
{ "which", required_argument, NULL, 'W' },
+ { NULL, 0, NULL, 0 },
};
int
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904072045.n37KjMxj013258>
