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)
```
This commit is contained in:
Pekka Ristola 2022-08-20 14:38:37 +03:00
parent 3a6fea5bb9
commit 41e504a7be
Failed to generate hash of commit

View file

@ -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;
}