libconfuse/libconfuse-d73777c2c3566fb2647727bb56d9a2295b81669b.patch
Dirk Mueller 424f8c88d7 Accepting request 1002767 from home:oertel:branches:devel:libraries:c_c++
- add fix from upstream git
  libconfuse-d73777c2c3566fb2647727bb56d9a2295b81669b.patch
  cfg_tilde_expand in confuse.c has a heap-based buffer over-read
  (CVE-2022-40320 boo#1203326)

OBS-URL: https://build.opensuse.org/request/show/1002767
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libconfuse?expand=0&rev=11
2022-09-12 14:58:28 +00:00

39 lines
1.0 KiB
Diff

commit d73777c2c3566fb2647727bb56d9a2295b81669b
Author: Joachim Wiberg <troglobit@gmail.com>
Date: Fri Sep 2 16:12:46 2022 +0200
Fix #163: unterminated username used with getpwnam()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
diff --git a/src/confuse.c b/src/confuse.c
index 6d1fdbd..05566b5 100644
--- a/src/confuse.c
+++ b/src/confuse.c
@@ -1894,18 +1894,20 @@ DLLIMPORT char *cfg_tilde_expand(const char *filename)
passwd = getpwuid(geteuid());
file = filename + 1;
} else {
- /* ~user or ~user/path */
- char *user;
+ char *user; /* ~user or ~user/path */
+ size_t len;
file = strchr(filename, '/');
- if (file == 0)
+ if (file == NULL)
file = filename + strlen(filename);
- user = malloc(file - filename);
+ len = file - filename - 1;
+ user = malloc(len + 1);
if (!user)
return NULL;
- strncpy(user, filename + 1, file - filename - 1);
+ strncpy(user, &filename[1], len);
+ user[len] = 0;
passwd = getpwnam(user);
free(user);
}