Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #10261

Re: Teaching C (was Re: hexump.c)

From pacman@kosh.dhis.org (Alan Curry)
Newsgroups comp.lang.c
Subject Re: Teaching C (was Re: hexump.c)
Date 2011-09-15 01:51 +0000
Organization Aioe.org NNTP Server
Message-ID <j4rlmm$cv6$1@speranza.aioe.org> (permalink)
References <j4ducg$lmn$1@speranza.aioe.org> <lnpqj2amz7.fsf@nuthaus.mib.org> <j4r4in$pv2$1@speranza.aioe.org> <4E711A9D.2030501@verizon.net>

Show all headers | View raw


In article <4E711A9D.2030501@verizon.net>,
James Kuyper  <jameskuyper@verizon.net> wrote:
>On 09/14/2011 04:59 PM, Alan Curry wrote:
>> 
>> I've just done this test on several programs. There were many segfaults.
>> Several print an angry message about argv[0] being NULL and then abort!
>> It seems to be a "you know exactly what you did and you should be
>> ashamed of yourself" type of error.
>> 
>> Most disturbing are the many setuid programs that segfaulted, including
>> passwd, mount, and su.
>> 
>> shells: pdksh, bash, and dash were OK. Others segfaulted.
>
>How many programs did you test? How many segfaulted?

I only picked a few examples of what I thought should be mature utilties with
a low bug count. Maybe about 20.

Here's a larger survey. Most of the versions are from the current Debian
release. The ratio got a little better as I added more, but crashing is still
a very popular option.

Behaves normally:
  7zr (9.04~dfsg.1-1)
  ar (binutils 2.20.1) [prints help as expected but program name is "(null)"]
  as (binutils 2.20.1)
  bash (4.1.5(1)-release) [$0 expands to "bash"]
  dash (0.5.5.1-7.4) [$0 expands to ""]
  false (coreutils 8.5)
  gpg (1.4.10)
  groff (1.20.1)
  pdksh (5.2.14-25) [$0 expands to "pdksh"]
  sed (4.2.1) [prints help as expected but program name is "(null)"]
  svn (1.6.12)
  true (coreutils 8.5)
  vim (7.2)
  w3m (0.5.2)
  xterm (261)

Segfaults and dies immediately:
  compress (ncompress 4.2.4.3)
  csh (20070713-2)
  cvs (1.12.13)
  ed (1.4)
  gcc (2.95.4, 4.4.5, and others)
  git (1.7.2.5)
  grep (2.5.1, locally modified)
  gzip (1.3.12)
  ksh (Version M 93s+ 2008-01-31)
  ld (binutils 2.20.1)
  less (436)
  man (1.5p)
  mawk (1.3.3)
  more (2.17.2)
  mount (2.17.2)
  nvi (1.81.6)
  passwd (shadow 4.1.4.2+svn3283-2, locally modified)
  pax (from an OpenBSD snapshot, I guess? 1:20090728-1)
  posh (0.8.5)
  su (shadow 4.1.4.2+svn3283-2, locally modified)
  tcsh (6.17.02)
  xboard (4.4.3)
  xz (5.0.0)
  zsh (4.3.10)

Segfaults, catches the signal, prints its own substitute for the standard
"Segmentation fault" message:
  bzip2 (1.0.5)
  gawk (3.1.7)
  unzip (6.00)

Complains specifically about argv[0] and aborts:
  cat, cp, ln, ls, mv (coreutils 8.5) [and presumably the rest of coreutils]
  diff (diffutils 3.0)
  tar (1.23)

Miscellaneous weird behavior:
  awk (2010-05-23)
    says "(null): no program given" (normal behavior with no arguments is to
    print a brief usage summary)
  nm (binutils 2.20.1)
    just exits 0, like /bin/true. (normal behavior with no arguments is to
    work on a.out)
  perl (5.10.1)
    somehow ends up confusing envp with argv, interprets envp[0] as the name
    of a script, fails to open it. If I create a perl script with that weird
    name, it executes normally, with @ARGV empty and $^X set to the actual
    full path to the perl executable.
  ping (iputils-sss20100418)
    reports that it is pinging hostname "(null)" which has IP address
    0.0.0.0, proceeds to ping it successfully (0.0.0.0 works like localhost)
  zip (3.0)
    if stdout is not a tty, compresses stdin to stdout which is normal
    behavior. If stdout is a tty, complains about attempt to compress to
    tty instead of printing help which would be normal behavior with no
    arguments.

-- 
Alan Curry

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

hexump.c jacob navia <jacob@spamsink.net> - 2011-09-09 22:53 +0200
  Re: hexump.c tea strainer <nospam@nospam.com> - 2011-09-09 21:06 +0000
    Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-09 23:57 +0200
    Re: hexump.c NicStevens <nic.stevens@gmail.com> - 2011-09-12 13:22 -0700
  Re: hexump.c Ian Collins <ian-news@hotmail.com> - 2011-09-10 09:18 +1200
    Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-09 23:59 +0200
  Re: hexump.c Ike Naar <ike@iceland.freeshell.org> - 2011-09-09 22:29 +0000
    Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 00:39 +0200
      Re: hexump.c Ike Naar <ike@iceland.freeshell.org> - 2011-09-09 22:53 +0000
        Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 00:58 +0200
        Re: hexump.c Seebs <usenet-nospam@seebs.net> - 2011-09-13 06:44 +0000
          Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-13 10:33 +0200
            Re: hexump.c Fritz Wuehler <fritz@spamexpire-201109.rodent.frell.theremailer.net> - 2011-09-13 18:02 +0200
            Teaching C (was Re: hexump.c) Kenneth Brody <kenbrody@spamcop.net> - 2011-09-13 16:36 -0400
              Re: Teaching C (was Re: hexump.c) jacob navia <jacob@spamsink.net> - 2011-09-13 22:44 +0200
                Re: Teaching C (was Re: hexump.c) Nobody <nobody@nowhere.com> - 2011-09-14 13:31 +0100
                Re: Teaching C (was Re: hexump.c) jacob navia <jacob@spamsink.net> - 2011-09-14 15:27 +0200
                Re: Teaching C (was Re: hexump.c) Richard Damon <news.x.richarddamon@xoxy.net> - 2011-09-14 11:49 -0400
                Re: Teaching C (was Re: hexump.c) Keith Thompson <kst-u@mib.org> - 2011-09-14 13:27 -0700
                Re: Teaching C (was Re: hexump.c) pacman@kosh.dhis.org (Alan Curry) - 2011-09-14 20:59 +0000
                Re: Teaching C (was Re: hexump.c) Nobody <nobody@nowhere.com> - 2011-09-14 22:20 +0100
                Re: Teaching C (was Re: hexump.c) James Kuyper <jameskuyper@verizon.net> - 2011-09-14 17:20 -0400
                Re: Teaching C (was Re: hexump.c) pacman@kosh.dhis.org (Alan Curry) - 2011-09-15 01:51 +0000
                Re: Teaching C (was Re: hexump.c) Keith Thompson <kst-u@mib.org> - 2011-09-14 19:29 -0700
                Re: Teaching C (was Re: hexump.c) Keith Thompson <kst-u@mib.org> - 2011-09-14 19:21 -0700
                Re: Teaching C Ben Pfaff <blp@cs.stanford.edu> - 2011-09-14 19:58 -0700
                Re: Teaching C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-14 21:55 -0600
                Re: Teaching C James Kuyper <jameskuyper@verizon.net> - 2011-09-15 06:54 -0400
                Re: Teaching C Keith Thompson <kst-u@mib.org> - 2011-09-15 11:58 -0700
                Re: Teaching C Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-24 12:57 -0800
                Re: Teaching C Nobody <nobody@nowhere.com> - 2011-09-15 14:25 +0100
                Re: Teaching C Seebs <usenet-nospam@seebs.net> - 2011-09-16 22:00 +0000
                Re: Teaching C (was Re: hexump.c) Kenneth Brody <kenbrody@spamcop.net> - 2011-09-14 12:54 -0400
                Re: Teaching C (was Re: hexump.c) James Kuyper <jameskuyper@verizon.net> - 2011-09-14 13:26 -0400
                Re: Teaching C (was Re: hexump.c) jacob navia <jacob@spamsink.net> - 2011-09-14 19:33 +0200
                Re: Teaching C (was Re: hexump.c) jameskuyper <jameskuyper@verizon.net> - 2011-09-14 11:33 -0700
                Re: Teaching C (was Re: hexump.c) jacob navia <jacob@spamsink.net> - 2011-09-14 21:17 +0200
                Re: Teaching C (was Re: hexump.c) Kenneth Brody <kenbrody@spamcop.net> - 2011-09-16 11:47 -0400
                Re: Teaching C (was Re: hexump.c) Seebs <usenet-nospam@seebs.net> - 2011-09-14 20:43 +0000
                Re: Teaching C (was Re: hexump.c) Nobody <nobody@nowhere.com> - 2011-09-14 22:35 +0100
                Re: Teaching C (was Re: hexump.c) gordonb.8a7i1@burditt.org (Gordon Burditt) - 2011-09-14 17:31 -0500
                Re: Teaching C (was Re: hexump.c) jacob navia <jacob@spamsink.net> - 2011-09-14 19:32 +0200
                Re: Teaching C (was Re: hexump.c) Kenneth Brody <kenbrody@spamcop.net> - 2011-09-16 11:27 -0400
                Re: Teaching C (was Re: hexump.c) Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-16 08:49 -0700
                Re: Teaching C (was Re: hexump.c) James Kuyper <jameskuyper@verizon.net> - 2011-09-17 15:04 -0400
            Re: hexump.c Keith Thompson <kst-u@mib.org> - 2011-09-13 20:31 -0700
              Re: hexump.c Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-14 03:22 -0700
              Re: hexump.c "BartC" <bc@freeuk.com> - 2011-09-14 11:40 +0100
                Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-14 13:54 +0200
                Re: hexump.c Nobody <nobody@nowhere.com> - 2011-09-14 13:50 +0100
                Re: hexump.c Keith Thompson <kst-u@mib.org> - 2011-09-14 11:35 -0700
                Re: hexump.c Seebs <usenet-nospam@seebs.net> - 2011-09-14 19:12 +0000
                Re: hexump.c John Bode <jfbode1029@gmail.com> - 2011-09-14 15:31 -0700
                Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-15 00:59 +0200
                Re: hexump.c Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-09-14 23:14 +0000
                Re: hexump.c John Bode <jfbode1029@gmail.com> - 2011-09-15 08:52 -0700
                Re: hexump.c Jens Gustedt <jens.gustedt@loria.fr> - 2011-09-14 21:22 +0200
                Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-14 21:26 +0200
                Re: hexump.c Ian Collins <ian-news@hotmail.com> - 2011-09-15 07:32 +1200
                Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-14 21:44 +0200
                Re: hexump.c Keith Thompson <kst-u@mib.org> - 2011-09-14 13:49 -0700
                Re: hexump.c Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-09-16 00:50 +0300
                Re: hexump.c Keith Thompson <kst-u@mib.org> - 2011-09-15 18:34 -0700
                Re: hexump.c Keith Thompson <kst-u@mib.org> - 2011-09-14 12:16 -0700
                Hypocrites jacob navia <jacob@spamsink.net> - 2011-09-14 21:40 +0200
                Re: Hypocrites Keith Thompson <kst-u@mib.org> - 2011-09-14 19:11 -0700
                Re: hexump.c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-14 15:05 +0100
                Re: hexump.c Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-14 07:56 -0700
                Re: hexump.c "BartC" <bc@freeuk.com> - 2011-09-14 17:23 +0100
              Re: hexump.c Seebs <usenet-nospam@seebs.net> - 2011-09-14 19:12 +0000
              Re: hexump.c John Bode <jfbode1029@gmail.com> - 2011-09-14 15:24 -0700
      Re: hexump.c gordonb.ik17p@burditt.org (Gordon Burditt) - 2011-09-09 18:16 -0500
        Re: hexump.c Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-12 22:24 +0000
  Re: hexump.c "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-09-09 20:33 -0400
    Re: hexump.c Ian Collins <ian-news@hotmail.com> - 2011-09-10 12:42 +1200
      Re: hexump.c "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-09-10 17:16 -0400
    Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 10:03 +0200
  Re: hexump.c Nobody <nobody@nowhere.com> - 2011-09-10 10:04 +0100
    Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 11:41 +0200
      Re: hexump.c pete <pfiland@mindspring.com> - 2011-09-10 05:51 -0400
        Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 12:38 +0200
          Re: hexump.c Nobody <nobody@nowhere.com> - 2011-09-10 17:53 +0100
  Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 12:46 +0200
    Re: hexump.c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-10 13:03 +0100
      Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-10 15:34 +0200
    Re: hexump.c "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-09-10 17:37 -0400
      Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-11 00:10 +0200
        Re: hexump.c Patrick Scheible <kkt@zipcon.net> - 2011-09-10 21:03 -0700
  Re: hexump.c Barry Schwarz <schwarz45@yahoo.com> - 2011-09-11 00:37 -0700
    Re: hexump.c jacob navia <jacob@spamsink.net> - 2011-09-11 13:56 +0200

csiph-web