aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-25 08:32:55 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-03-29 15:35:38 +0200
commitf41f0416b837925bc8612f45ca58432218ce6707 (patch)
tree59039803e062cc4bb3a73276d2bc70b2f38d2dfd
parent54d9df39033730234540cee49393d40cdfe3658a (diff)
downloadpasst-f41f0416b837925bc8612f45ca58432218ce6707.tar
passt-f41f0416b837925bc8612f45ca58432218ce6707.tar.gz
passt-f41f0416b837925bc8612f45ca58432218ce6707.tar.bz2
passt-f41f0416b837925bc8612f45ca58432218ce6707.tar.lz
passt-f41f0416b837925bc8612f45ca58432218ce6707.tar.xz
passt-f41f0416b837925bc8612f45ca58432218ce6707.tar.zst
passt-f41f0416b837925bc8612f45ca58432218ce6707.zip
dhcp: Minimum option length implied by RFC 951 is 60 bytes, not 62
In section 3 ("Packet Format"), "vend" is 64 bytes long, minus the magic that's 60 bytes, not 62. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--dhcp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/dhcp.c b/dhcp.c
index 197a515..d24ef86 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -57,6 +57,8 @@ static struct opt opts[255];
#define DHCPINFORM 8
#define DHCPFORCERENEW 9
+#define OPT_MIN 60 /* RFC 951 */
+
/**
* dhcp_init() - Initialise DHCP options
*/
@@ -158,9 +160,9 @@ static int fill(struct msg *m)
m->o[offset++] = 255;
m->o[offset++] = 0;
- if (offset < 62 /* RFC 951 */) {
- memset(&m->o[offset], 0, 62 - offset);
- offset = 62;
+ if (offset < OPT_MIN) {
+ memset(&m->o[offset], 0, OPT_MIN - offset);
+ offset = OPT_MIN;
}
return offset;