Re: Problem with VS and memcpy...



The excat code is:


int number = 25;
int offSet = 16000;
unsigned char header[8];
header[0] = 0;
header[1] = 255;
header[2] = 0;
header[3] = number>>8;
header[4] = number;
header[5] = offSet>>16;
header[6] = offSet>>8;
header[7] = offSet;

memcpy(buffer, header, sizeof header);


John Carson ha scritto:

"Paolo" <paomic@xxxxxxxxx> wrote in message
news:1151573245.812709.93530@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yes I amde some mistakes in the code, I couldn't paste because it was
too long.

Yes, the correct lines are

unsigned char* buffer = new unsigned char[1000];

and

memcpy(buf, temp, sizeof temp);

I didn't use the redundant casts at first, but then I added them, but
nothing changed.

The problem isI just can't see why if I use the debugger before the
memcpy I can see something like

buffer = 0x01234456 "yqhsfjkvdfdsfhfe"

Where "yqhsfjkvdfdsfhfe" ius the content of the buffer, but after
thememcpy it becomes

buffer = 0x01234456 ""

Is it normal?

The content of buffer will only be displayed up until the first terminating
zero. It looks to me like temp has a terminating zero (i.e., '\0') as its
first character.

You need to give us code that actually exhibits the problem (and no other
problem). Code that looks like your code but doesn't have the problem is
useless.

--
John Carson

.



Relevant Pages

  • Re: In-tree version of new FireWire drivers available
    ... Just to recap, the dual buffer receive mode, as described in section ... quadlet aligned amount of header data can be appended into one buffer ... *either* the header buffer or the payload buffer fills up. ... enough to hold headers for all the packets it takes to fill up the ...
    (Linux-Kernel)
  • [Full-disclosure] n.runs-SA-2009.001 - OS X CFNetwork advisory
    ... 2009/04/17 Initial notification of Apple including n.runs RFP ... A remotely exploitable vulnerability has been found in the HTTP header ... result is either stored in a local stack buffer or in a buffer ... the vulnerability allows remote code ...
    (Full-Disclosure)
  • n.runs-SA-2009.001 - OS X CFNetwork advisory
    ... 2009/04/17 Initial notification of Apple including n.runs RFP ... A remotely exploitable vulnerability has been found in the HTTP header ... result is either stored in a local stack buffer or in a buffer ... the vulnerability allows remote code ...
    (Bugtraq)
  • Need help interfacing Gnu "as" to fpc (very specific)
    ... days I have been looking at AT&T syntax for the Gnu assembler ... The header is the problem ... buffer visible in fpc. ...
    (comp.lang.pascal.misc)
  • Re: Correlating SecondaryBuffer PlayCursor Position and Time in VB.NET
    ... be to load on the fly, having perhaps just the next buffer after the one ... but have all the clips loaded into memory. ... There is a header, followed by ... The fmt chunk marker is folloed by a DWORD ...
    (microsoft.public.win32.programmer.directx.audio)