Article View: gnu.gdb.bug
Article #116environ.c should not apply memcpy to overlapping regions (GDB 4.6)
From: Paul Eggert
Date: Thu, 23 Jul 1992 23:40
Date: Thu, 23 Jul 1992 23:40
30 lines
1241 bytes
1241 bytes
GDB 4.6's environ.c applies the memcpy routine to overlapping regions of
memory. This isn't portable. It should use memmove instead, but I suppose
that's too much of a pain to configure. Here is a patch.
===================================================================
RCS file: environ.c,v
retrieving revision 4.6
diff -c -r4.6 environ.c
*** environ.c 1992/07/06 17:10:46 4.6
--- environ.c 1992/07/23 23:27:13
***************
*** 179,187 ****
&& s[len] == '=')
{
free (s);
! memcpy (vector, vector + 1,
! (e->allocated - (vector - e->vector)) * sizeof (char *));
! e->vector[e->allocated - 1] = 0;
return;
}
}
--- 179,186 ----
&& s[len] == '=')
{
free (s);
! while ((vector[0] = vector[1]) != NULL)
! vector++;
return;
}
}
Technical Details
Message-ID:
<9207232340.AA20418@farside.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!twinsun.COM!eggertShow Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!twinsun.COM!eggert From: eggert@twinsun.COM (Paul Eggert) Subject: environ.c should not apply memcpy to overlapping regions (GDB 4.6) Message-ID: <9207232340.AA20418@farside.twinsun.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 23 Jul 1992 23:40:45 GMT Approved: bug-gdb@prep.ai.mit.edu Lines: 31