[openssh-commits] [openssh] 01/05: upstream: Save return value from sshbuf_len instead of calling it
git+noreply at mindrot.org
git+noreply at mindrot.org
Mon Jun 16 20:07:12 AEST 2025
This is an automated email from the git hooks/post-receive script.
dtucker pushed a commit to branch master
in repository openssh.
commit bd1bd7e8296aa51a4b3958cef2fbb17894ba94e9
Author: dtucker at openbsd.org <dtucker at openbsd.org>
AuthorDate: Mon Jun 16 08:49:27 2025 +0000
upstream: Save return value from sshbuf_len instead of calling it
multiple times. Fixes Coverity CID 470521.
OpenBSD-Regress-ID: 356b8b43c8a232deaf445c1ff7526577b177a8e9
---
regress/unittests/sshkey/common.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c
index a579eccb2..edb1d95fa 100644
--- a/regress/unittests/sshkey/common.c
+++ b/regress/unittests/sshkey/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.7 2025/05/06 06:05:48 djm Exp $ */
+/* $OpenBSD: common.c,v 1.8 2025/06/16 08:49:27 dtucker Exp $ */
/*
* Helpers for key API tests
*
@@ -53,13 +53,13 @@ load_text_file(const char *name)
{
struct sshbuf *ret = load_file(name);
const u_char *p;
+ size_t len;
/* Trim whitespace at EOL */
- for (p = sshbuf_ptr(ret); sshbuf_len(ret) > 0;) {
- if (p[sshbuf_len(ret) - 1] == '\r' ||
- p[sshbuf_len(ret) - 1] == '\t' ||
- p[sshbuf_len(ret) - 1] == ' ' ||
- p[sshbuf_len(ret) - 1] == '\n')
+ for (p = sshbuf_ptr(ret); (len = sshbuf_len(ret)) > 0;) {
+ len--;
+ if (p[len] == '\r' || p[len] == '\t' ||
+ p[len] == ' ' || p[len] == '\n')
ASSERT_INT_EQ(sshbuf_consume_end(ret, 1), 0);
else
break;
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list