On 2005-05-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
> I am facing a very usual problem. My application run fine on zire and
> tungsten series, but on Treo600 it crashes.
> Output of debug is as follows. The HashedStringCompare Function doesn't
> return to position from where it is called. instead it again start
> execution from the 153 lines. Please help me out
>
> m68k-palmos-gdb -command=debugfile Fortress
> GNU gdb 5.3-tvo-20031229
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "--host=i686-pc-linux-gnu --target=m68k-palmos"...
> debugfile:1: Error in sourced command file:
> localhost:2000: Connection refused.
> (gdb) target palmos
> Remote debugging under PalmOS using localhost:2000
> Waiting... (Press Ctrl-C to connect to halted machine)
>
> Program received signal SIGSTOP, Stopped (signal).
> PilotMain (cmd=0, cmdPBP=0x0, launchFlags=174) at Fortress.c:7362
> 7362 UInt32 alarmTime = 0,nowTime = 0;
> (gdb) b 8539
> No line 8539 in file "Fortress.c".
> (gdb) b 5839
> Breakpoint 1 at 0x11106794: file Fortress.c, line 5839.
> (gdb) c
> Continuing.
>
> Breakpoint 1, SetPassword3FormHandleEvent (eventP=0x102d69c4) at
> Fortress.c:5839
> 5839
> GetFieldText(SetPassword3FormField,&passwordString);
> (gdb) n
> 5840 StrCopy(digest,passwordString);
> (gdb) n
> 5841 result = HashedStringCompare(gMasterPassword,
> digest);
> (gdb) s
> HashedStringCompare (
> hashedString=0x10027684 "?o8\n��|[EMAIL PROTECTED]",
> newString=0x102d4910 "a") at crypto.c:149
> 149 MemSet(digest, kMD5HashSize, 0);
> (gdb) n
> 150 StrCopy(digest, newString);
> (gdb) n
> 151 GetMD5HashedString( digest );
> (gdb) n
> 153 result = StrCompare(hashedString, digest);
> (gdb) n
> 154 StrCopy(newString, digest);
> (gdb) n
> 157 return true;
> (gdb) n
> 0x1110736e 160 }
> (gdb) n
> 153 result = StrCompare(hashedString, digest);
> (gdb) n
> 154 StrCopy(newString, digest);
> (gdb) n
>
>
>
> Heres is the Function
> Boolean HashedStringCompare( CharPtr hashedString, CharPtr newString){
> Int8 result = 0;
> Char digest[kMD5HashSize];
> MemSet(digest, kMD5HashSize, 0);
> StrCopy(digest, newString);
> GetMD5HashedString( digest );
> // if(digest != 0 && hashedString != 0)
> result = StrCompare(hashedString, digest);
> StrCopy(newString, digest);
>
> // if(result == 0)
> return true;
> // else
> // return false;
> }
>
> Regards
> Deepak Singh
Your digest string is a local variable and hence on the stack. Check if
the StrCopy calls do not overwrite the allocated storage for digest.
If they do, they might overwrite the return address (also on the stack)
and hence the function returns to some arbitrary location.
Maybe you were just lucky on Zire and Tungsten.
Inspect your strings and use assembly level debugging to inspect memory.
HTH
Ton van Overbeek
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/