Re: Using c runtime funcs on a BSTR



The buffer is 10 characters. Pass any larger string and you
get buffer overrun. I suggest at the very least you should use
snprintf() instead...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

<sbrade@xxxxxxxxx> wrote in message
news:1138233352.111135.29480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Thanks for both your replies.
>
> I have just inherited this code base and am going over the layout of
> the classes and trying to understand their inner workings & am
> stumbling across various patterns that I'm concerned about, and am
> looking for feedback on improvements or issues with code that's just
> plain wrong and that needs fixing. I have found out that there are
> various memory leaks that have been detected in the field and hence the
> concern.
>
> So, besides the check for an NULL Input string, is your recommendation
> that the call to sprintf may not cause any issues & be left as-is?
>
> Thanks,
> Braden.
>


.



Relevant Pages

  • Re: Whats wrong
    ... local machine user, ... Microsoft MVP ... > FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, ... > sourceControl, String eventArgument) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: FP2000 VBA: objects, methods for graphics, links?
    ... > Thomas A. Rowe (Microsoft MVP - FrontPage) ... >> capital letters, and this may be causing me problems (got a thread on ... I thought if I could write every name to a string, ... >>> What you want to do is already built into FrontPage. ...
    (microsoft.public.frontpage.programming)
  • Re: Database Connection
    ... I even tried to manually registering VFPOLEDB.DLL and the ... > CONNECTION STRING: ... > No error information available: ... >> Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: __declspec(dllexport) to return char but errors in VB6
    ... After reading a little feather in to StrCpy ... I foud that I'm causing a buffer overrun by coping more than the origial ... > String, ... or provide another function that frees the memory later. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: HELP, INFINIT LOOP... simple LINKED LIST
    ... > typedef struct node ... > void AddNode(List *L, String item) ... which is what gives you undefined behaviour in the above code). ... Danger of buffer overrun attack by careless or malicious user. ...
    (comp.lang.c)