[ovs-dev,v2] conntrack: Remove unnecessary check in process_ftp_ctl_v4

Message ID 1549853574-17643-1-git-send-email-lirongqing@baidu.com
State New
Headers show
Series
  • [ovs-dev,v2] conntrack: Remove unnecessary check in process_ftp_ctl_v4
Related show

Commit Message

Li RongQing Feb. 11, 2019, 2:52 a.m.
It has been assured that both first and second int from ftp
command are not bigger than 255, so their combination(first
int << 8 +second int) must not bigger than 65535

Co-authored-by: Wang Li <wangli39@baidu.com>
Signed-off-by: Wang Li <wangli39@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Cc: Darrell Ball <dlu998@gmail.com>
---
 lib/conntrack.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Ben Pfaff Feb. 12, 2019, 1:57 a.m. | #1
On Mon, Feb 11, 2019 at 10:52:54AM +0800, Li RongQing wrote:
> It has been assured that both first and second int from ftp
> command are not bigger than 255, so their combination(first
> int << 8 +second int) must not bigger than 65535
> 
> Co-authored-by: Wang Li <wangli39@baidu.com>
> Signed-off-by: Wang Li <wangli39@baidu.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Cc: Darrell Ball <dlu998@gmail.com>

Thanks, applied to master.

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 6b46d0ca3..315a19e9e 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -2997,12 +2997,7 @@  process_ftp_ctl_v4(struct conntrack *ct,
         return CT_FTP_CTL_INVALID;
     }
 
-    uint16_t port_lo_hs = value;
-    if (65535 - port_hs < port_lo_hs) {
-        return CT_FTP_CTL_INVALID;
-    }
-
-    port_hs |= port_lo_hs;
+    port_hs |= value;
     ovs_be16 port = htons(port_hs);
     ovs_be32 conn_ipv4_addr;