C Does strcpy needs specific buffer size or will still work? -


I have decompiled an application and I do not know the size of the real array so I have made it very big, but I wonder. What do I need to do is use strcpy or should I consider the size of strcpy ?
  signed int __cdecl SendSomePacket (structure connection * conn, int a1, int a2, const char * a3) {// char buf [256]; // [SP + 10H] [BP-9H] @ one four buff [10]; // [SP + 10H] [BP-9H] @ 1 * (unsigned full *) and Buff [1] = A1; * (Unsigned integer *) and buff [5] = A2; Strapepie (and Buff [9], A3); Buf [0] = 0xEu; // Packet Type Returns SendPacket (CONNECTION-> Socket, Buff, Stellen (A3) + 10, 1); }   

I should ask that it should be left with 256 which estimates the default size by which always 2 is like 256,512,1024,2048 .. < / P>

  four buff [256]; // [SP + 10H] [BP-9H] @ 1   

Or I should reduce as much as possible to save the memory.

  char bf [10]; // [SP + 9H] [BP-9H] @ 1   

to which buffer I have applied after the string (A3) Should be bigger.

I tried just strakpy with the buffer size of 10. And I put a length of more than 500 in a string and maybe this work might have been lucky. I just wanted to know whether I should make enough static buffer for data from the initial packet + strakpy or just for the packet?

This will be copied as many letters as in the source string . It is not known how big a destination buffer is, and if you are giving it a very long source string it will be overwritten in random area. There is no "default size" in it and not exactly "guess".

Be careful, it seems like how you work the basics, it is not quite clear at all.

If you already know the length of the source, it is memcpy () .

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -