Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 697672 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/dhcp.c (-6 / +13 lines)
Lines 164-171 dhcp_printoptions(const struct dhcpcd_ctx *ctx, Link Here
164
	}
164
	}
165
}
165
}
166
166
167
#define get_option_raw(ctx, bootp, bootp_len, opt)	\
168
	get_option((ctx), (bootp), (bootp_len), NULL)
169
static const uint8_t *
167
static const uint8_t *
170
get_option(struct dhcpcd_ctx *ctx,
168
get_option(struct dhcpcd_ctx *ctx,
171
    const struct bootp *bootp, size_t bootp_len,
169
    const struct bootp *bootp, size_t bootp_len,
Lines 3277-3283 is_packet_udp_bootp(void *packet, size_t plen) Link Here
3277
	size_t ip_hlen;
3275
	size_t ip_hlen;
3278
	struct udphdr *udp;
3276
	struct udphdr *udp;
3279
3277
3280
	if (sizeof(*ip) > plen)
3278
	if (plen < sizeof(*ip))
3281
		return false;
3279
		return false;
3282
3280
3283
	if (ip->ip_v != IPVERSION || ip->ip_p != IPPROTO_UDP)
3281
	if (ip->ip_v != IPVERSION || ip->ip_p != IPPROTO_UDP)
Lines 3288-3299 is_packet_udp_bootp(void *packet, size_t plen) Link Here
3288
		return false;
3286
		return false;
3289
3287
3290
	ip_hlen = (size_t)ip->ip_hl * 4;
3288
	ip_hlen = (size_t)ip->ip_hl * 4;
3289
	if (ip_hlen < sizeof(*ip))
3290
		return false;
3291
3291
	/* Check we have a UDP header and BOOTP. */
3292
	/* Check we have a UDP header and BOOTP. */
3292
	if (ip_hlen + sizeof(*udp) + offsetof(struct bootp, vend) > plen)
3293
	if (ip_hlen + sizeof(*udp) + offsetof(struct bootp, vend) > plen)
3293
		return false;
3294
		return false;
3294
3295
3295
	/* Check it's to and from the right ports. */
3296
	/* Sanity. */
3296
	udp = (struct udphdr *)(void *)((char *)ip + ip_hlen);
3297
	udp = (struct udphdr *)(void *)((char *)ip + ip_hlen);
3298
	if (ntohs(udp->uh_ulen) < sizeof(*udp))
3299
		return false;
3300
	if (ip_hlen + ntohs(udp->uh_ulen) != plen)
3301
		return false;
3302
3303
	/* Check it's to and from the right ports. */
3297
	if (udp->uh_dport != htons(BOOTPC) || udp->uh_sport != htons(BOOTPS))
3304
	if (udp->uh_dport != htons(BOOTPC) || udp->uh_sport != htons(BOOTPS))
3298
		return false;
3305
		return false;
3299
3306
Lines 3324-3334 checksums_valid(void *packet, Link Here
3324
		return false;
3331
		return false;
3325
3332
3326
	if (flags & BPF_PARTIALCSUM)
3333
	if (flags & BPF_PARTIALCSUM)
3327
		return 0;
3334
		return true;
3328
3335
3329
	udp = (struct udphdr *)(void *)((char *)ip + ip_hlen);
3336
	udp = (struct udphdr *)(void *)((char *)ip + ip_hlen);
3330
	if (udp->uh_sum == 0)
3337
	if (udp->uh_sum == 0)
3331
		return 0;
3338
		return true;
3332
3339
3333
	/* UDP checksum is based on a pseudo IP header alongside
3340
	/* UDP checksum is based on a pseudo IP header alongside
3334
	 * the UDP header and payload. */
3341
	 * the UDP header and payload. */

Return to bug 697672