From c36d7187a8de4b39d7879a752f5933de9689de6b Mon Sep 17 00:00:00 2001
From: hiura <hiuramr-mail.yahoo.co.jp>
Date: Tue, 16 Apr 2024 10:30:10 +0900
Subject: [PATCH 1/2] Fix 'RemoveDefGwOnDhcpForLocalhost' function No.2: Change
 the minimum size of DHCP reply

---
 src/Mayaqua/TcpIp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/Mayaqua/TcpIp.c b/src/Mayaqua/TcpIp.c
index 7c3abddb..21cc14e9 100644
--- a/src/Mayaqua/TcpIp.c
+++ b/src/Mayaqua/TcpIp.c
@@ -4168,6 +4168,7 @@ BUF *DhcpModify(DHCP_MODIFY_OPTION *m, void *data, UINT size)
 	LIST *opt_list2 = NULL;
 	UINT src_size = size;
 	UINT i;
+	UINT dhcp_min_size;
 	// Validate arguments
 	if (m == NULL || data == NULL || size == 0)
 	{
@@ -4270,11 +4271,13 @@ BUF *DhcpModify(DHCP_MODIFY_OPTION *m, void *data, UINT size)
 		// Rewrite if anything changes. Do not rewrite if there is no change
 		ret_ok = true;
 
-		if (ret->Size < DHCP_MIN_SIZE)
+		// If src_size is greater than DHCP_MIN_SIZE, then use the src_size as minimum size of DHCP.
+		dhcp_min_size = max(src_size, DHCP_MIN_SIZE);
+		if (ret->Size < dhcp_min_size)
 		{
 			// Padding
 			UCHAR *pad_buf;
-			UINT pad_size = DHCP_MIN_SIZE - ret->Size;
+			UINT pad_size = dhcp_min_size - ret->Size;
 
 			pad_buf = ZeroMalloc(pad_size);
 

From 9a009d750aac2416ee15515df8639eed2ba8215f Mon Sep 17 00:00:00 2001
From: hiura <hiuramr-mail.yahoo.co.jp>
Date: Tue, 16 Apr 2024 19:14:44 +0900
Subject: [PATCH 2/2] Use macro 'MAX' instead of 'max'

---
 src/Mayaqua/TcpIp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Mayaqua/TcpIp.c b/src/Mayaqua/TcpIp.c
index 21cc14e9..8dba45e2 100644
--- a/src/Mayaqua/TcpIp.c
+++ b/src/Mayaqua/TcpIp.c
@@ -4272,7 +4272,7 @@ BUF *DhcpModify(DHCP_MODIFY_OPTION *m, void *data, UINT size)
 		ret_ok = true;
 
 		// If src_size is greater than DHCP_MIN_SIZE, then use the src_size as minimum size of DHCP.
-		dhcp_min_size = max(src_size, DHCP_MIN_SIZE);
+		dhcp_min_size = MAX(src_size, DHCP_MIN_SIZE);
 		if (ret->Size < dhcp_min_size)
 		{
 			// Padding