[Openvpn-devel,XS] Change in openvpn[master]: buf_string_match_head_str: Fix Coverity issue "Unsigned compared agai...

Message ID 77b603bc7e5a745a4e88f37c194cb081860c9c61-HTML@gerrit.openvpn.net
State Superseded
Headers show
Series [Openvpn-devel,XS] Change in openvpn[master]: buf_string_match_head_str: Fix Coverity issue "Unsigned compared agai... | expand

Commit Message

flichtenheld (Code Review) Jan. 9, 2024, 11:09 a.m. UTC
Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/491?usp=email

to review the following change.


Change subject: buf_string_match_head_str: Fix Coverity issue "Unsigned compared against 0"
......................................................................

buf_string_match_head_str: Fix Coverity issue "Unsigned compared against 0"

As Coverity says:
An unsigned value can never be negative, so this test will always
evaluate the same way.

Was changed from int to size_t in commit
7fc608da4ec388c9209bd009cd5053ac0ff7df38 which triggered warning,
but the check did not make sense before, either.

Change-Id: I64f094eeb0ca8c3953a94d742adf468faf27dab3
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
M src/openvpn/buffer.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/91/491/1

Patch

diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index 0b94a52..2ad3461 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -822,7 +822,7 @@ 
 buf_string_match_head_str(const struct buffer *src, const char *match)
 {
     const size_t size = strlen(match);
-    if (size < 0 || size > src->len)
+    if (size > src->len)
     {
         return false;
     }