Skip to contentSkip to conversation

Change in openvpn[master]: buf_string_match_head_str: Fix Coverity issue "Unsigned compared agai...

Openvpn-devel In review flichtenheld (Code Review) 2 participants 7 messages Jan 9, 2024 – Jan 19, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1704798536000.I64f094eeb0ca8c3953a94d742adf468faf27dab3@...2715...

#1 lore raw

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

---
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

src/openvpn/buffer.c +1 -1
index 0b94a52..2ad3461 100644
@@ -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;
     }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/491?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I64f094eeb0ca8c3953a94d742adf468faf27dab3
Gerrit-Change-Number: 491
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/491?usp=email )

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

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/491?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I64f094eeb0ca8c3953a94d742adf468faf27dab3
Gerrit-Change-Number: 491
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 19 Jan 2024 11:56:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/491?usp=email )

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

Patch Set 1:

(1 comment)

Patchset:

PS1:
This looks like it might have been written with strcmp in mind or something like that but for the current code the < 0 makes indeed no sense.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/491?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I64f094eeb0ca8c3953a94d742adf468faf27dab3
Gerrit-Change-Number: 491
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 19 Jan 2024 11:58:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#4 lore raw

PATCH 1/1 buf_string_match_head_str: Fix Coverity issue "Unsigned compared against 0"

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

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

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/491
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

src/openvpn/buffer.c +1 -1
index 0b94a52..2ad3461 100644
@@ -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;
     }
#5 lore raw

[Openvpn-devel] [PATCH applied] Re: buf_string_match_head_str: Fix Coverity issue 'Unsigned compared against 0'

Arguably coverity is right here :-)

Your patch has been applied to the master and release/2.6 branch (bugfix).

commit bc29bd6a3376158b73d069758122739fbf93c022 (master) commit 68b00a54e779325f4ac9d9416b4e85261f771c23 (release/2.6)

Author: Frank Lichtenheld
Date:   Fri Jan 19 13:03:41 2024 +0100
     buf_string_match_head_str: Fix Coverity issue 'Unsigned compared against 0'

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg28093.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#6 lore raw

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

In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/491?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

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

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28093.html

---
M src/openvpn/buffer.c

1 file changed, 1 insertion(+), 1 deletion(-)

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

src/openvpn/buffer.c +1 -1
index 0b94a52..2ad3461 100644
@@ -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;
     }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/491?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I64f094eeb0ca8c3953a94d742adf468faf27dab3
Gerrit-Change-Number: 491
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#7 lore raw

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

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/491?usp=email )

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

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28093.html

---
M src/openvpn/buffer.c

1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/buffer.c +1 -1
index 0b94a52..2ad3461 100644
@@ -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;
     }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/491?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I64f094eeb0ca8c3953a94d742adf468faf27dab3
Gerrit-Change-Number: 491
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged