1195972f6Sopenharmony_ciFrom 003d34eebd223c16a3dbf6a970bb6e23cb7d1a24 Mon Sep 17 00:00:00 2001 2195972f6Sopenharmony_ciFrom: Simon Goldschmidt <goldsimon@gmx.de> 3195972f6Sopenharmony_ciDate: Fri, 27 Mar 2020 22:59:05 +0100 4195972f6Sopenharmony_ciSubject: [PATCH] tcp: fix sequence number comparison 5195972f6Sopenharmony_ciThis fixes both undefined behavior (see bug #51447) as well as a possible bug 6195972f6Sopenharmony_ciwhere sequence numbers in 31 bit distance may come through. 7195972f6Sopenharmony_ciConflict: NA 8195972f6Sopenharmony_ciReference: https://git.savannah.gnu.org/cgit/lwip.git/commit/?id=003d34eebd223c16a3dbf6a970bb6e23cb7d1a24 9195972f6Sopenharmony_ci--- 10195972f6Sopenharmony_ci src/include/lwip/priv/tcp_priv.h | 11 ++++------- 11195972f6Sopenharmony_ci 1 file changed, 4 insertions(+), 7 deletions(-) 12195972f6Sopenharmony_cidiff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h 13195972f6Sopenharmony_ciindex 72f9126d..c84b5be8 100644 14195972f6Sopenharmony_ci--- a/src/include/lwip/priv/tcp_priv.h 15195972f6Sopenharmony_ci+++ b/src/include/lwip/priv/tcp_priv.h 16195972f6Sopenharmony_ci@@ -106,14 +106,11 @@ err_t tcp_process_refused_data(struct tcp_pcb *pcb); 17195972f6Sopenharmony_ci #define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) 18195972f6Sopenharmony_ci 19195972f6Sopenharmony_ci 20195972f6Sopenharmony_ci-#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) 21195972f6Sopenharmony_ci-#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) 22195972f6Sopenharmony_ci-#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) 23195972f6Sopenharmony_ci-#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) 24195972f6Sopenharmony_ci+#define TCP_SEQ_LT(a,b) (((u32_t)((u32_t)(a) - (u32_t)(b)) & 0x80000000u) != 0) 25195972f6Sopenharmony_ci+#define TCP_SEQ_LEQ(a,b) (!(TCP_SEQ_LT(b,a))) 26195972f6Sopenharmony_ci+#define TCP_SEQ_GT(a,b) TCP_SEQ_LT(b,a) 27195972f6Sopenharmony_ci+#define TCP_SEQ_GEQ(a,b) TCP_SEQ_LEQ(b,a) 28195972f6Sopenharmony_ci /* is b<=a<=c? */ 29195972f6Sopenharmony_ci-#if 0 /* see bug #10548 */ 30195972f6Sopenharmony_ci-#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) 31195972f6Sopenharmony_ci-#endif 32195972f6Sopenharmony_ci #define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) 33195972f6Sopenharmony_ci 34195972f6Sopenharmony_ci #ifndef TCP_TMR_INTERVAL 35195972f6Sopenharmony_ci-- 36195972f6Sopenharmony_ci2.28.0.windows.1 37