Deeply convinced through face

Character Copy function:

https://www.cnblogs.com/lxy-xf/p/11517873.html

There are two main problems:

1. Buffer Overflow: if src dst is greater than the length, will be assigned to the dst \ 0, the buffer overflow.

2. Memory overlap: if src and dst located src + strlen (src) between, if you copy from the beginning will cause memory overlap, if \ 0 to terminate the copy is never stopped

strcpy,strncpy,strlcpy:

strcpy:

Incoming dst and src, to \ 0 is terminated, it could cause a buffer overflow

strncpy:

Copies n characters into dst area, without ending \ 0.

strlcpy:

strcpy secure version, its argument is dst, src and sizeof (dst). If the src than dst is truncated to the sizeof (dst) size prevent buffer overflow.

Memory alignment:

https://www.douban.com/group/topic/128339995/

1. Data alignment members: placed min (data member length, length of the alignment default) position of an integer multiple of

2. Align the overall structure: filled min (maximum length of the data member, the default alignment length) integer multiple positions

string implementation

https://www.cnblogs.com/zhizhan/p/4876093.html

How to send a signal to other processes

kill function

UDP uses connect, bind:

UDP is a connectionless protocol, so UDP socket function connect seems to be meaningless, however, is not the case. A socket has several attributes, including a protocol, a local address / port, destination address / port. For UDP speaking, socket function creates a socket; the bind function indicating the local address / port (including ADDR_ANY, wild all local network interfaces); Connect can be used to indicate the destination address / port; In general, UDP client establishing after the socket is sent directly sendto function data, you need to specify the destination address / port sendto function's parameters. If a UDP client socket after the establishment of the first with the connect function indicates the destination address / port, then you can also send data send function, because the send function already know each other address / port, with getsockname can also get this information. UDP client sends after the establishment of a jack directly sendto function data, also implies an operation, that is, before sending data, for the first UDP socket will select (between 1024-5000) a separate UDP port , the bound state has been set to the socket. If a client is established UDP socket with the bind function indicates the first local address / port, are also possible, so that can be forced to use UDP port designated transmission data. (In fact, UDP server and client matter, where the boundaries have blurred.) UDP server may be used connect, as described above, can be used to indicate Connect destination address / port; this causes the server to accept only a specific host requests.

socket related functions

Analyzing Endian

 

Guess you like

Origin www.cnblogs.com/lxy-xf/p/11668620.html