[Top][All Lists]

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

Re: Overflow Bug

From: Greg Wooledge
Subject: Re: Overflow Bug
Date: Fri, 13 Jul 2012 08:34:42 -0400
User-agent: Mutt/

On Fri, Jul 13, 2012 at 08:53:25AM +0300, Pierre Gaston wrote:
> On Thu, Jul 12, 2012 at 8:09 PM, Ernesto Messina
> <address@hidden> wrote:
> > Hello, I think I found an overflow bug. I got the follow C program:
> >
> > #include <stdio.h>
> > #include <string.h>
> >
> > int main(int argc, char *argv[])
> > {
> >     char a[10];
> >     int i;
> >
> >     strcpy(a, argv[1]);
> >
> >   return 0;
> > }
> >
> > Compiling with: gcc program.c -o program
> > And running: program `perl -e 'print "a" x 24'`
> >
> > The terminal loses the control, entering into a infinite buckle, and
> bash is not the terminal and is not involved once the program runs,
> and yes, writing buggy programs can cause buggy behaviour. On this
> system man strcpy says under BUGS:

It's not even related to the terminal, either.  The C program does not
perform any input or output at all (despite the <stdio.h> include).
Your platform goes into an infinite loop when you run this program,
so the terminal just sits there waiting for output that never arrives.
Bash just sits there waiting for its child process (your C program) to
terminate, which it never does (until you hit Ctrl-C or whatever your
terminal has mapped to Interrupt).

So, it's not a bug in either bash or the terminal.  It's a bug in your
C program.

reply via email to

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