Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 May 1995 07:41:21 +0200
From:      "Philippe Charnier" <charnier@lirmm.fr>
To:        bugs@FreeBSD.org
Subject:   bug in sh (core dumped)
Message-ID:  <199505050541.HAA12977@lirmm.lirmm.fr>

next in thread | raw e-mail | index | archive | help


Hello,

There is a bug in sh: the built in command "fc -l" generates
a core dump (*NULL in not_fcnumber).

According to the sh manual page (fc  -l [-nr] [first [last]]), fc -l
is a correct sequence (in that case, values are defaulted to -16 and -1)
but fails when first is not given.

The program enters histcmd (in histedit.c)  and then run the code:

        optreset = 1; optind = 1; /* initialize getopt */
        while (not_fcnumber(argv[optind]) &&
              (ch = getopt(argc, argv, ":e:lnrs")) != EOF)
                switch ((char)ch) {   
                case 'e':
                        editor = optarg;
                        break;
                case 'l':
                        lflg = 1;     
                ...
                }
argv[0] is "fc"
argv[1] is "-l"

The second loop runs not_fcnumber(NULL) (in histedit.c) and fails.

*** histedit.c.orig	Fri May  5 07:35:05 1995
--- histedit.c	Fri May  5 07:38:29 1995
***************
*** 389,395 ****
  not_fcnumber(s)
          char *s;
  {
!         if (*s == '-')
                  s++;
  	return (!is_number(s));
  }
--- 389,399 ----
  not_fcnumber(s)
          char *s;
  {
! 	if (s == NULL) {
! 	  /* *NULL is not a fc_number */
! 	  return (1);
! 	}
! 	if (*s == '-')
                  s++;
  	return (!is_number(s));
  }


--------                                                        --------
Philippe Charnier                                      charnier@lirmm.fr
                               

         LIRMM, 161 rue Ada, 34392 Montpellier cedex 5 -- France
------------------------------------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199505050541.HAA12977>