[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segmentation fault using shift_verbose option

From: Felipe Kellermann
Subject: Segmentation fault using shift_verbose option
Date: Mon, 9 Feb 2004 17:39:13 -0200 (BRST)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: openbsd3.4
Compiler: cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc'
-DCONF_OSTYPE='openbsd3.4' -DCONF_MACHTYPE='sparc-unknown-openbsd3.4'
-I/usr/ports/shells/bash2/w-bash-2.05b/bash-2.05b/lib  -O2
uname output: OpenBSD kodiak.nyvra.org 3.4 GENERIC#65 sparc
Machine Type: sparc-unknown-openbsd3.4

Bash Version: 2.05b
Patch Level: 0
Release Status: release

        When using the 'shift_verbose' option and doing a 'shift' without
specifying an argument (which is probably the most common use), the shell
function 'shift_builtin' calls 'sh_erange' with a NULL pointer, causing a
segmentation fault.

        $ bash
        bash-2.05b$ shopt shift_verbose
        shift_verbose   off
        bash-2.05b$ echo $#
        bash-2.05b$ shift
        bash-2.05b$ shopt -s shift_verbose
        bash-2.05b$ shift
        Memory fault (core dumped)

        To fix the problem we shouldn't pass the list when it's null:

--- builtins/shift.def- Mon Feb  9 15:46:57 2004
+++ builtins/shift.def  Mon Feb  9 15:47:24 2004
@@ -68,7 +68,7 @@ shift_builtin (list)
   else if (times > number_of_args ())
       if (print_shift_error)
-       sh_erange (list->word->word, "shift count");
+       sh_erange (list ? list->word->word : "0", "shift count");
       return (EXECUTION_FAILURE);

Felipe Kellermann

reply via email to

[Prev in Thread] Current Thread [Next in Thread]