mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
evutil: don't call memset before memcpy
In `evutil_parse_sockaddr_port`, it would `memset` the `out` to zero, however, the `memset` is unnecessary before `memcpy`, and may cause undefined behavior if the `outlen` is invalid. This should close #1573.
This commit is contained in:
parent
4fd07f0ee8
commit
39073df831
2
evutil.c
2
evutil.c
@ -2379,7 +2379,6 @@ evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *
|
||||
if ((int)sizeof(sin6) > *outlen)
|
||||
return -1;
|
||||
sin6.sin6_scope_id = if_index;
|
||||
memset(out, 0, *outlen);
|
||||
memcpy(out, &sin6, sizeof(sin6));
|
||||
*outlen = sizeof(sin6);
|
||||
return 0;
|
||||
@ -2398,7 +2397,6 @@ evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *
|
||||
return -1;
|
||||
if ((int)sizeof(sin) > *outlen)
|
||||
return -1;
|
||||
memset(out, 0, *outlen);
|
||||
memcpy(out, &sin, sizeof(sin));
|
||||
*outlen = sizeof(sin);
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user