1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
From: Peter Pentchev <roam@ringlet.net>
Date: Tue, 25 Jul 2023 14:56:23 +0300
Subject: Fix some cppcheck warnings.
Forwarded: no
Last-Update: 2023-07-25
---
lib/address.c | 2 +-
lib/clientprotocol.c | 7 ++++++-
lib/config_parse.c | 2 +-
lib/config_parse.y | 2 +-
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/address.c b/lib/address.c
index 864b5f6..f1cf11d 100644
--- a/lib/address.c
+++ b/lib/address.c
@@ -1259,8 +1259,8 @@ socks_addrinit(void)
serr("%s: mutex_init() failed", function);
}
}
-#endif /* HAVE_PTHREAD_H */
}
+#endif /* HAVE_PTHREAD_H */
inited = 1;
doing_addrinit = 0;
diff --git a/lib/clientprotocol.c b/lib/clientprotocol.c
index 0d117ee..159823b 100644
--- a/lib/clientprotocol.c
+++ b/lib/clientprotocol.c
@@ -1219,7 +1219,12 @@ clientmethod_gssapi(s, protocol, gw, version, auth, emsg, emsglen)
SOCKS_SIGUNBLOCK_IF_CLIENT(&oldset);
if (gss_err_isset(major_status, minor_status, tmpbuf, sizeof(tmpbuf))) {
- snprintf(emsg, emsglen, "gss_import_name() failed: %s", emsg);
+ char *ebuf = malloc(emsglen);
+ if (ebuf != NULL) {
+ snprintf(ebuf, emsglen, "%s", emsg);
+ snprintf(emsg, emsglen, "gss_import_name() failed: %s", ebuf);
+ free(ebuf);
+ }
SOCKS_SIGUNBLOCK_IF_CLIENT(&oldset);
goto error;
diff --git a/lib/config_parse.c b/lib/config_parse.c
index 2561678..d562894 100644
--- a/lib/config_parse.c
+++ b/lib/config_parse.c
@@ -3594,7 +3594,7 @@ yyreduce:
#if !SOCKS_CLIENT
static ruleaddr_t mem;
struct servent *service;
- serverstate_t statemem;
+ static serverstate_t statemem;
bzero(&statemem, sizeof(statemem));
state = &statemem;
diff --git a/lib/config_parse.y b/lib/config_parse.y
index a989aa6..b05e2c4 100644
--- a/lib/config_parse.y
+++ b/lib/config_parse.y
@@ -1001,7 +1001,7 @@ internalinit: {
#if !SOCKS_CLIENT
static ruleaddr_t mem;
struct servent *service;
- serverstate_t statemem;
+ static serverstate_t statemem;
bzero(&statemem, sizeof(statemem));
state = &statemem;
|