[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gEDA-dev: Stack corruption PCB bug in hid_parse_actions????
On Wed, 2006-09-06 at 17:48 +0100, Peter Clifton wrote:
> Looks like a nasty stack corruption, as whilst argv[0] moves its
> location by 2 bytes (and IIRC, its always this ammount), argv[0] still
> evaluates to the same string.. as if a portion of the stack has been
> shifted. (Cant have shifted all of it, as the function return appears
to
> be ok) (Evaluation of argv[0] as string not shown in output below)
>
> And program output - from an instrumented version of PCB:
Since it might be useful to make sense of the output below, attached is
the patch which adds the instrumentation I used to produce the output
originally in my email.
Peter
Index: src/action.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/action.c,v
retrieving revision 1.90
diff -U3 -p -r1.90 action.c
--- src/action.c 18 Aug 2006 03:30:57 -0000 1.90
+++ src/action.c 6 Sep 2006 17:00:37 -0000
@@ -6402,6 +6402,8 @@ ActionExecuteFile (int argc, char **argv
AFAIL (executefile);
fname = argv[0];
+ printf( "fname is %s\n", fname );
+ printf( "2 argv[0]=%p, fname=%p\n", argv[0],fname );
if ((fp = fopen (fname, "r")) == NULL)
{
@@ -6409,8 +6411,10 @@ ActionExecuteFile (int argc, char **argv
return 1;
}
+ printf( "3 argv[0]=%p, fname=%p\n", argv[0],fname );
while (fgets (line, sizeof (line), fp) != NULL)
{
+ printf( "4 argv[0]=%p, fname=%p\n", argv[0],fname );
n++;
sp = line;
@@ -6431,6 +6435,9 @@ ActionExecuteFile (int argc, char **argv
if (*sp && *sp != '#')
{
+ printf( "fname %p, is \"%s\"\n", fname, fname );
+ printf( "n is \"%i\"\n", n );
+ printf( "sp %p, is \"%s\"\n", sp, sp );
Message ("%s : line %-3d : \"%s\"\n", fname, n, sp);
hid_parse_actions (sp, 0);
}
Index: src/hid/common/actions.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/common/actions.c,v
retrieving revision 1.8
diff -U3 -p -r1.8 actions.c
--- src/hid/common/actions.c 20 Apr 2006 03:23:07 -0000 1.8
+++ src/hid/common/actions.c 6 Sep 2006 17:00:37 -0000
@@ -227,6 +227,8 @@ hid_parse_actions (const char *rstr,
char *sp, *aname, *sp2;
int maybe_empty = 0;
+ printf( "hid_parse_actions: rstr %p, is \"%s\", function %p\n", rstr, rstr, function );
+
if (function == NULL)
function = hid_actionv;
@@ -258,6 +260,7 @@ another:
* we didn't find a leading ( so invoke the action
* with no parameters or event.
*/
+ printf( "hid_parse_actions: sp %p, is \"%s\", aname %p, is \"%s\" \n", sp,sp,aname, aname );
if (!*sp)
{
if (function (aname, 0, 0))
@@ -270,6 +273,7 @@ another:
* action
*/
*sp++ = 0;
+ printf( "hid_parse_actions: sp %p, is \"%s\", aname %p, is \"%s\" \n", sp,sp,aname, aname );
while (1)
{
/*
@@ -279,6 +283,7 @@ another:
if (*sp == ')' && !maybe_empty)
{
*sp++ = 0;
+ printf( "hid_parse_actions: sp %p, is \"%s\", aname %p, is \"%s\" \n", sp,sp,aname, aname );
if (function (aname, num, list))
return 1;
goto another;
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev