[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C program segfaults when run, not under GDB
- To: Max Kovgan <smcmaugh(at-nospam)techst02.technion.ac.il>
- Subject: Re: C program segfaults when run, not under GDB
- From: mulix <mulix(at-nospam)actcom.co.il>
- Date: Sun, 25 Nov 2001 12:43:11 +0200 (IST)
- Cc: <milesteg(at-nospam)surfree.net.il>, <linux-il(at-nospam)linux.org.il>
- Delivered-To: linux.org.il-linux-il@linux.org.il
- In-Reply-To: <Pine.GSO.4.33.0111251213360.8525-100000@techst02.technion.ac.il>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
the problem here isn't a buffer overflow, i'm afraid. the problem here
is that s1 and s2 are in a read only section of the executable, and
trying to modify s1 is forbidden.
consider this snippet, which produces a SIGSEGV as well:
void foo(char s[]){
s[0] = 'b';
}
int main()
{
foo("a");
return 0;
}
On Sun, 25 Nov 2001, Max Kovgan wrote:
> this line:
> if (factor!=0) s1[c1]=s1[c1+factor];
> tries to see behind the s1's end after the index (length_of_s1 - factor)
> is reached.
> this causes SIGSEG
> it's not nice to ask people to debug your own homework :))))))
>
> bye
>
> -=O0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~O0=-
> "Beware the Jabberwock, my son!
> The jaws that bite, the claws that catch!
> Beware the Jubjub bird, and shun
> The frumious Bandersnatch!"
>
> [L.Carrol "Jabberwacky"]
>
> On Sun, 25 Nov 2001, Eugene Romm wrote:
>
> > Hello.
> >
> > I've written a procedure that's supposed to remove all occurances of
> > string2 from string1 (parameters).
> > For reasons I do not understand, the program compiles but segfaults when
> > run from the command prompt, but silently executes without a warning
> > when run under GDB. Attached is the program. Segfault occurs on line 29,
> > as far as I can tell.
--
mulix
http://www.pointer.co.il/~mulix/
http://syscalltrack.sf.net/
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il