libext2fs: fix uninitialized length in rep_strdup()
For platforms whose libc don't supply strdup(), the replacement strdup
function in lib/ext2fs/tdb.c needs to always initialize the length
variable.
Reported-by: Vladyslav Tsilytskyi <ykp@protonmail.ch>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/lib/ext2fs/tdb.c b/lib/ext2fs/tdb.c
index 195a4c0..5091b12 100644
--- a/lib/ext2fs/tdb.c
+++ b/lib/ext2fs/tdb.c
@@ -79,12 +79,10 @@
{
char *ret;
int length;
+
if (!s)
return NULL;
-
- if (!length)
- length = strlen(s);
-
+ length = strlen(s);
ret = malloc(length + 1);
if (ret) {
strncpy(ret, s, length);