you're right ..according to this given example,
it's a constant string, so it is inside the executable,
and is read only,and when gdb runs the binary,
it probably opens it in other (protected)
memory space in writeable mode.

but i'll try to protect my statement :
if the string is accepted not as constant, there still is
a potential overflow in this code and a sigsegv may be sent.


-=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, mulix wrote:

> 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 [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

  • C p... Eugene Romm
    • ... Max Kovgan
    • ... Vlad
    • ... Oleg Goldshmidt
    • ... Yaacov Fenster - System Engineering Troubleshooting and other miracles
    • ... Behdad Esfahbod

Reply via email to