[pacman-dev] [PATCH 1/2] check for valid optarg before using strdup
Allan McRae
allan at archlinux.org
Mon Apr 26 03:18:13 CEST 2010
On 26/04/10 02:48, Serge Ziryukin wrote:
> Signed-off-by: Serge Ziryukin<ftrvxmtrx at gmail.com>
> ---
> src/pacman/pacman.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
> index d32d4d1..206cdcf 100644
> --- a/src/pacman/pacman.c
> +++ b/src/pacman/pacman.c
> @@ -489,6 +489,7 @@ static int parseargs(int argc, char *argv[])
> setarch(optarg);
> break;
> case OP_PRINTFORMAT:
> + check_optarg();
> config->print_format = strdup(optarg);
> break;
> case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break;
Looks good. Although, in all likelihood it will rarely capture the
missing argument:
pacman -Sp --print-format kdelibs
error: no targets specified (use -h for help)
pacman -Sp kdelibs --print-format
pacman: option '--print-format' requires an argument
Pulled to my working branch.
Allan
More information about the pacman-dev
mailing list