From: "flichtenheld (Code Review)"
Date: Tue, 10 Mar 2026 13:21:27 +0000
In-Reply-To:
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net, gert@...1296...
Message-ID: <09f0af54cb9b950520d24319486c9126cb4bc88c-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="IFWjbGxGsUk="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: socket: Avoid
sign-compare issue by comparing before assignment
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos
Cc: openvpn-devel
--IFWjbGxGsUk=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1523?usp=3Demail
to look at the new patch set (#4).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied=
now.
Change subject: socket: Avoid sign-compare issue by comparing before assign=
ment
......................................................................
socket: Avoid sign-compare issue by comparing before assignment
The assignment implicitly converts the values, but
we can just do the comparison before the assignment.
Change-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40
Signed-off-by: Frank Lichtenheld
---
M src/openvpn/socket.c
1 file changed, 2 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/1523/4
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 8d2d110..5df0792 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -2550,11 +2550,6 @@
return WSAGetLastError();
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
int
socket_recv_queue(struct link_socket *sock, int maxsize)
{
@@ -2579,11 +2574,10 @@
/* Win32 docs say it's okay to allocate the wsabuf on the stack */
wsabuf[0].buf =3D BSTR(&sock->reads.buf);
+ /* make sure maxsize is sane */
+ ASSERT(maxsize <=3D BLEN(&sock->reads.buf));
wsabuf[0].len =3D maxsize ? maxsize : BLEN(&sock->reads.buf);
- /* check for buffer overflow */
- ASSERT(wsabuf[0].len <=3D BLEN(&sock->reads.buf));
-
/* the overlapped read will signal this event on I/O completion */
ASSERT(ResetEvent(sock->reads.overlapped.hEvent));
sock->reads.flags =3D 0;
@@ -2656,10 +2650,6 @@
return sock->reads.iostate;
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
int
socket_send_queue(struct link_socket *sock, struct buffer *buf, const stru=
ct link_socket_actual *to)
{
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1523?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40
Gerrit-Change-Number: 1523
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: cron2
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
Gerrit-Attention: flichtenheld
--IFWjbGxGsUk=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: flichtenheld, plaisthos.
flichtenheld uploaded patch set #4 to this change.
<=
p>View C=
hange
The change is no longer submittable: checks~ChecksSubmitRul=
e is unsatisfied now.
socket: Avoid sign-compare issue by =
comparing before assignment
The assignment implicitly converts the v=
alues, but
we can just do the comparison before the assignment.
C=
hange-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40
Signed-off-by: Frank=
Lichtenheld <frank@...2641...>
---
M src/openvpn/socket.c
1=
file changed, 2 insertions(+), 12 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/1523/4
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 8d2d110..5df0792 100644
--- a/src/openvpn/socket.c<=
/span>
+++ b/src/openvpn/socket.c
@@ -2550,11 +255=
0,6 @@
return WSAGetLastError();
}
-#if de=
fined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare&q=
uot;
-#endif
=
-
int
=
socket_recv_queue(struct link_socket *sock, int maxsize)
<=
span> {
@@ -2579,11 +2574,10 @@
/* Win32 docs say it's okay to allocate the wsabuf on t=
he stack */
wsabuf[0].buf =3D BSTR(&sock->r=
eads.buf);
+ /=
* make sure maxsize is sane */
+ ASSERT(maxsize <=3D BLEN(&sock->reads.buf));=
span>
wsabuf[0].len =3D maxsize ? maxsize : BLEN(&soc=
k->reads.buf);
- /* check for buffer overflow */
- ASSERT(wsabuf[0].len <=3D BLEN(&=
amp;sock->reads.buf));
-
/* the overlapped read will signal this event=
on I/O completion */
ASSERT(ResetEvent(sock->r=
eads.overlapped.hEvent));
sock->reads.flags =3D=
0;
@@ -2656,10 +2650,6 @@
return sock=
->reads.iostate;
}
-#if defined(__GNUC__) || defined(__clang=
__)
-#pragma GCC diagno=
stic pop
-#endif=
-
int=
socket_send_queue(struct link_socket *sock, struct buffer *buf, =
const struct link_socket_actual *to)
{
To view, visit change 1523. To unsubscribe, or for help writin=
g mail filters, visit settings.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Idf5ce8f82e7727505cce67560e0=
b7423b8e41a40
Gerrit-Change-Number: 1523
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <frank@...2723...=
.>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...=
..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
=
--IFWjbGxGsUk=--