From 41e504a7be9790d5bf1e1375ead5589103e4ba9c Mon Sep 17 00:00:00 2001 From: Pekka Ristola Date: Sat, 20 Aug 2022 14:38:37 +0300 Subject: [PATCH] Fix use of uninitialized value Contents of string `content` are unitialized before copying of `dummy_content`. Using `g_strlcat` appends `dummy_content` to the uninitialized junk, and by changing that to `strcpy` the uninitialized values aren't used. Relevant Valgrind error when running zathura with no arguments: ``` ==15845== Conditional jump or move depends on uninitialised value(s) ==15845== at 0x566EB2D: UnknownInlinedFun (gstrfuncs.c:1534) ==15845== by 0x566EB2D: g_strlcat (gstrfuncs.c:1521) ==15845== by 0x12B16D: zathura_db_read_key_file_from_file (database-plain.c:171) ==15845== by 0x12D39D: UnknownInlinedFun (database-plain.c:295) ==15845== by 0x12D39D: plain_set_property (database-plain.c:371) ==15845== by 0x55C17AD: object_set_property (gobject.c:1607) ==15845== by 0x55C1C1C: g_object_new_internal (gobject.c:2047) ==15845== by 0x55C3307: g_object_new_valist (gobject.c:2355) ==15845== by 0x55C383D: g_object_new (gobject.c:1824) ==15845== by 0x117944: UnknownInlinedFun (database-plain.c:226) ==15845== by 0x117944: init_database (zathura.c:373) ==15845== by 0x11B8EA: zathura_init (zathura.c:473) ==15845== by 0x114B99: UnknownInlinedFun (main.c:111) ==15845== by 0x114B99: main (main.c:282) ``` --- zathura/database-plain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zathura/database-plain.c b/zathura/database-plain.c index 7af68c1..e5ae751 100644 --- a/zathura/database-plain.c +++ b/zathura/database-plain.c @@ -168,7 +168,7 @@ zathura_db_read_key_file_from_file(const char* path) g_key_file_free(key_file); return NULL; } - g_strlcat(content, dummy_content, dummy_len + 1); + strcpy(content, dummy_content); contentlen = dummy_len; }