diff options
| author | Michael Biebl <biebl@debian.org> | 2020-08-19 10:13:49 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-08-19 10:13:49 +0200 |
| commit | e7b44ef4c80907346ec7492a09c45277459924fc (patch) | |
| tree | b1388af193ca205f73336eca47e81815e43a61ca /shared | |
| parent | 136d191f1c96dbae1489fed7c2565f5e1b1f8d40 (diff) | |
New upstream version 1.26.2 upstream/1.26.2
Diffstat (limited to 'shared')
| -rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-c-connection.c | 23 | ||||
| -rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-socket.c | 4 | ||||
| -rw-r--r-- | shared/n-dhcp4/src/util/packet.c | 12 | ||||
| -rw-r--r-- | shared/nm-glib-aux/nm-macros-internal.h | 8 | ||||
| -rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.c | 5 | ||||
| -rw-r--r-- | shared/nm-version-macros.h | 2 |
6 files changed, 26 insertions, 28 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c index 8c32a984..701df1f6 100644 --- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c +++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c @@ -182,7 +182,8 @@ int n_dhcp4_c_connection_listen(NDhcp4CConnection *connection) { int n_dhcp4_c_connection_connect(NDhcp4CConnection *connection, const struct in_addr *client, const struct in_addr *server) { - int r, fd_udp; + _c_cleanup_(c_closep) int fd_udp = -1; + int r; c_assert(connection->state == N_DHCP4_C_CONNECTION_STATE_PACKET); @@ -200,27 +201,21 @@ int n_dhcp4_c_connection_connect(NDhcp4CConnection *connection, .events = EPOLLIN, .data = { .u32 = N_DHCP4_CLIENT_EPOLL_IO }, }); - if (r < 0) { - r = -errno; - goto exit_fd; - } + if (r < 0) + return -errno; r = packet_shutdown(connection->fd_packet); - if (r < 0) - goto exit_epoll; + if (r < 0) { + epoll_ctl(connection->fd_epoll, EPOLL_CTL_DEL, fd_udp, NULL); + return r; + } connection->state = N_DHCP4_C_CONNECTION_STATE_DRAINING; connection->fd_udp = fd_udp; + fd_udp = -1; connection->client_ip = client->s_addr; connection->server_ip = server->s_addr; - fd_udp = -1; return 0; - -exit_epoll: - epoll_ctl(connection->fd_epoll, EPOLL_CTL_DEL, fd_udp, NULL); -exit_fd: - close(fd_udp); - return r; } void n_dhcp4_c_connection_close(NDhcp4CConnection *connection) { diff --git a/shared/n-dhcp4/src/n-dhcp4-socket.c b/shared/n-dhcp4/src/n-dhcp4-socket.c index c7e89772..7291c780 100644 --- a/shared/n-dhcp4/src/n-dhcp4-socket.c +++ b/shared/n-dhcp4/src/n-dhcp4-socket.c @@ -50,8 +50,8 @@ int n_dhcp4_c_socket_packet_new(int *sockfdp, int ifindex) { BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 1, 0), /* IP protocol == UDP ? */ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ - BPF_STMT(BPF_LD + BPF_B + BPF_ABS, offsetof(struct iphdr, frag_off)), /* A <- Flags */ - BPF_STMT(BPF_ALU + BPF_AND + BPF_K, ntohs(IP_MF | IP_OFFMASK)), /* A <- A & (IP_MF | IP_OFFMASK) */ + BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(struct iphdr, frag_off)), /* A <- Flags + Fragment offset */ + BPF_STMT(BPF_ALU + BPF_AND + BPF_K, IP_MF | IP_OFFMASK), /* A <- A & (IP_MF | IP_OFFMASK) */ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 1, 0), /* fragmented packet ? */ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ diff --git a/shared/n-dhcp4/src/util/packet.c b/shared/n-dhcp4/src/util/packet.c index 38cb399d..95e65940 100644 --- a/shared/n-dhcp4/src/util/packet.c +++ b/shared/n-dhcp4/src/util/packet.c @@ -293,6 +293,8 @@ int packet_recvfrom_udp(int sockfd, ssize_t pktlen; size_t hdrlen; + *n_transmittedp = 0; + /* Peek packet to obtain the real IP header length */ pktlen = recv(sockfd, &ip_hdr.hdr, sizeof(ip_hdr.hdr), MSG_PEEK); if (pktlen < 0) @@ -304,7 +306,6 @@ int packet_recvfrom_udp(int sockfd, * discard it. */ recv(sockfd, NULL, 0, 0); - *n_transmittedp = 0; return 0; } @@ -313,7 +314,6 @@ int packet_recvfrom_udp(int sockfd, * This is not an IPv4 packet, discard it. */ recv(sockfd, NULL, 0, 0); - *n_transmittedp = 0; return 0; } @@ -324,7 +324,6 @@ int packet_recvfrom_udp(int sockfd, * header length, discard the packet. */ recv(sockfd, NULL, 0, 0); - *n_transmittedp = 0; return 0; } @@ -354,7 +353,6 @@ int packet_recvfrom_udp(int sockfd, * provided too small a buffer. In both cases, we simply drop * the packet. */ - *n_transmittedp = 0; return 0; } @@ -366,14 +364,12 @@ int packet_recvfrom_udp(int sockfd, * The packet is too small to even contain an entire UDP * header, so discard it entirely. */ - *n_transmittedp = 0; return 0; } else if ((size_t)pktlen < hdrlen + ntohs(udp_hdr.len)) { /* * The UDP header specified a longer length than the returned * packet, so discard it entirely. */ - *n_transmittedp = 0; return 0; } @@ -386,13 +382,10 @@ int packet_recvfrom_udp(int sockfd, /* IP */ if (ip_hdr.hdr.protocol != IPPROTO_UDP) { - *n_transmittedp = 0; return 0; /* not a UDP packet, discard it */ } else if (ip_hdr.hdr.frag_off & htons(IP_MF | IP_OFFMASK)) { - *n_transmittedp = 0; return 0; /* fragmented packet, discard it */ } else if (checksum && packet_internet_checksum(ip_hdr.data, hdrlen)) { - *n_transmittedp = 0; return 0; /* invalid checksum, discard it */ } @@ -411,7 +404,6 @@ int packet_recvfrom_udp(int sockfd, buf, pktlen, udp_hdr.check)) { - *n_transmittedp = 0; return 0; } } diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index f56ed856..15bcd7e5 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -732,6 +732,10 @@ NM_G_ERROR_MSG (GError *error) #define _NM_IN_SET_EVAL_14(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_13 (op, _x, __VA_ARGS__) #define _NM_IN_SET_EVAL_15(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_14 (op, _x, __VA_ARGS__) #define _NM_IN_SET_EVAL_16(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_15 (op, _x, __VA_ARGS__) +#define _NM_IN_SET_EVAL_17(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_16 (op, _x, __VA_ARGS__) +#define _NM_IN_SET_EVAL_18(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_17 (op, _x, __VA_ARGS__) +#define _NM_IN_SET_EVAL_19(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_18 (op, _x, __VA_ARGS__) +#define _NM_IN_SET_EVAL_20(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_19 (op, _x, __VA_ARGS__) #define _NM_IN_SET_EVAL_N2(op, _x, n, ...) (_NM_IN_SET_EVAL_##n(op, _x, __VA_ARGS__)) #define _NM_IN_SET_EVAL_N(op, type, x, n, ...) \ @@ -798,6 +802,10 @@ _NM_IN_STRSET_streq (const char *x, const char *s) #define _NM_IN_STRSET_EVAL_14(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_13 (op, _x, __VA_ARGS__) #define _NM_IN_STRSET_EVAL_15(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_14 (op, _x, __VA_ARGS__) #define _NM_IN_STRSET_EVAL_16(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_15 (op, _x, __VA_ARGS__) +#define _NM_IN_STRSET_EVAL_17(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_16 (op, _x, __VA_ARGS__) +#define _NM_IN_STRSET_EVAL_18(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_17 (op, _x, __VA_ARGS__) +#define _NM_IN_STRSET_EVAL_19(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_18 (op, _x, __VA_ARGS__) +#define _NM_IN_STRSET_EVAL_20(op, _x, y, ...) _NM_IN_STRSET_streq (_x, y) op _NM_IN_STRSET_EVAL_19 (op, _x, __VA_ARGS__) #define _NM_IN_STRSET_EVAL_N2(op, _x, n, ...) (_NM_IN_STRSET_EVAL_##n(op, _x, __VA_ARGS__)) #define _NM_IN_STRSET_EVAL_N(op, x, n, ...) \ diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 681b4dd1..3d1b0098 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -4194,7 +4194,10 @@ nm_utils_hexstr2bin_alloc (const char *hexstr, guint8 *buffer; gsize buffer_len, len; - g_return_val_if_fail (hexstr, NULL); + if (G_UNLIKELY (!hexstr)) { + NM_SET_OUT (out_len, 0); + g_return_val_if_fail (hexstr, NULL); + } nm_assert (required_len > 0 || out_len); diff --git a/shared/nm-version-macros.h b/shared/nm-version-macros.h index 5feb98ca..629f1e32 100644 --- a/shared/nm-version-macros.h +++ b/shared/nm-version-macros.h @@ -30,7 +30,7 @@ * Evaluates to the micro version number of NetworkManager which this source * compiled against. */ -#define NM_MICRO_VERSION (0) +#define NM_MICRO_VERSION (2) /** * NM_CHECK_VERSION: |