mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
fix build warning with af_alg
This commit is contained in:
@ -36,11 +36,20 @@
|
|||||||
/* Sets the type of socket address to use */
|
/* Sets the type of socket address to use */
|
||||||
void wc_Afalg_SockAddr(struct sockaddr_alg* in, const char* type, const char* name)
|
void wc_Afalg_SockAddr(struct sockaddr_alg* in, const char* type, const char* name)
|
||||||
{
|
{
|
||||||
|
int typeSz = (int)XSTRLEN(type) + 1; /* +1 for null terminator */
|
||||||
|
int nameSz = (int)XSTRLEN(name) + 1; /* +1 for null terminator */
|
||||||
|
|
||||||
|
if (typeSz > (int)sizeof(in->salg_type) ||
|
||||||
|
nameSz > (int)sizeof(in->salg_name)) {
|
||||||
|
WOLFSSL_MSG("type or name was too large");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
in->salg_family = AF_ALG;
|
in->salg_family = AF_ALG;
|
||||||
XSTRNCPY((char*)in->salg_type, type, XSTRLEN(type));
|
XSTRNCPY((char*)in->salg_type, type, typeSz);
|
||||||
in->salg_type[XSTRLEN(type)] = '\0';
|
in->salg_type[typeSz - 1] = '\0';
|
||||||
XSTRNCPY((char*)in->salg_name, name, XSTRLEN(name));
|
XSTRNCPY((char*)in->salg_name, name, nameSz);
|
||||||
in->salg_name[XSTRLEN(name)] = '\0';
|
in->salg_name[nameSz - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user