actually found by cferris@ *running* valgrind, but ykwim.
--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From d25f4df605e62a1e8bc396cbaadc973214f3d6c1 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Fri, 11 Dec 2015 15:25:32 -0800
Subject: [PATCH] Fix use of uninitialized value in ls.
Caught by valgrind.
==59779== Conditional jump or move depends on uninitialised value(s)
==59779== at 0x41BC91: listfiles (/tmp/toybox/toys/posix/ls.c:353)
==59779== by 0x41BB45: listfiles (/tmp/toybox/toys/posix/ls.c:311)
==59779== by 0x41C5D5: ls_main (/tmp/toybox/toys/posix/ls.c:558)
==59779== by 0x409C20: toy_exec (/tmp/toybox/main.c:143)
==59779== by 0x409C5D: toybox_main (/tmp/toybox/main.c:156)
==59779== by 0x409C20: toy_exec (/tmp/toybox/main.c:143)
==59779== by 0x409C5D: toybox_main (/tmp/toybox/main.c:156)
==59779== by 0x4054EA: main (/tmp/toybox/main.c:215)
==59779== Uninitialised value was created by a stack allocation
==59779== at 0x41BA7B: listfiles (/tmp/toybox/toys/posix/ls.c:287)
---
toys/posix/ls.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 04f6415..0c1752a 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -299,6 +299,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
}
memset(totals, 0, sizeof(totals));
+ memset(len, 0, sizeof(len));
// Top level directory was already populated by main()
if (!indir->parent) {
--
2.6.0.rc2.230.g3dd15c0
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net