summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2023-03-21 10:33:34 +0100
committerWerner Koch <wk@gnupg.org>2023-03-21 10:34:52 +0100
commit68333be63042be281a497a5751474e9e3d119dc3 (patch)
tree124736ef0d6cbb03a49718324065e9cdc062821d
parentfbbc55b3febef6d22dae5e2675c75b1d1f561b09 (diff)
downloadlibgpg-error-68333be63042be281a497a5751474e9e3d119dc3.tar.gz
Avoid segv in logging with improper use of the "socket://" .
* src/logging.c (fun_writer): Protect calling socket_dir_cb if not set. -- If no callback has been registered the use of the "socket://" shortcut caused a segv.
-rw-r--r--src/logging.c4
-rw-r--r--src/sysutils.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/logging.c b/src/logging.c
index 96adce3..9008ba4 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -249,7 +249,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
srvr_addr_un.sun_family = af;
if (!*name)
{
- if ((name = socket_dir_cb ()) && *name
+ if (socket_dir_cb && (name = socket_dir_cb ()) && *name
&& strlen (name) + 7 < sizeof (srvr_addr_un.sun_path)-1)
{
strncpy (srvr_addr_un.sun_path,
@@ -887,7 +887,7 @@ _gpgrt_logv_internal (int level, int ignore_arg_ptr, const char *extrastring,
if (ignore_arg_ptr)
{ /* This is used by log_string and comes with the extra
- * feature that after a LF the next line is indent at the
+ * feature that after a LF the next line is indented by the
* length of the prefix. Note that we do not yet include
* the length of the timestamp and pid in the indent
* computation. */
diff --git a/src/sysutils.c b/src/sysutils.c
index 1251ed6..fac72bf 100644
--- a/src/sysutils.c
+++ b/src/sysutils.c
@@ -141,6 +141,10 @@ _gpgrt_setenv (const char *name, const char *value, int overwrite)
if (!value && overwrite)
{
+ /* Deleting an envvar. Although the Microsoft specs for
+ * putenv tell us that one may use "NAME=" to unset an envvar,
+ * this seems not to be correct. Thus we do the same as what
+ * we do in Unix (or well in GNU libc) and use just "NAME". */
if (!SetEnvironmentVariable (name, NULL))
return GPG_ERR_EINVAL;
if (getenv (name))