>
> Or to check that cmdptr/cmdLength are non-NULL/0 before calling
> StrNCopy, perhaps?

I thought that a check for cmdptr!=NULL was redundant as cmdptr is obtained
from a non-NULL handle. Check for cmdLength maybe. (Although it is difficult
to imagine a zero-byte data on the clipboard.) Anyway, this was not the
problem. (The string on the clipboard was non-empty.)

>
> Yes; one could paraphrase this fix as "make StrNCopy act more like
> strncpy" (details in my reply to the more recent thread below).

Exactly - that's it.

----
Strange - I searched the forum for ClipboardGetItem string before posting,
but did not receive the links you list bellow.


----- Original Message -----
From: "John Marshall" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, September 19, 2003 3:04 PM
Subject: Re: ClipboardGetItem and StrNCopy


> Jan Slodicka wrote:
> >  MemHandle hCmd = ClipboardGetItem( clipboardText, &cmdLength) ;
> [...]
> >   StrNCopy( cmd, cmdPtr, cmdLength ) ;       // This fails on accessing
> > low memory address
> [...]
> > The problem is that StrNCopy() accesses cmdPtr[cmdLength]. The cure to
> > the problem is to replace StrNCopy by MemMove.
>
> Or to check that cmdptr/cmdLength are non-NULL/0 before calling
> StrNCopy, perhaps?
>
> > I guess if StrNCopy was implemented differently (if the test on the
> > string length preceded the terminator test), there would not be any
> > problem.
>
> Yes; one could paraphrase this fix as "make StrNCopy act more like
> strncpy" (details in my reply to the more recent thread below).
>
> This issue last came up three years ago:
>
> http://www.escribe.com/computing/pcpef/m1998.html
>
> and the previous time was apparently two years before that:
>
> http://www.egroups.com/message/palm-dev-forum/2812
>
>     John  "stay tuned for a reappearance in 2007? :-)"
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to