busybox
Variable 'info' is uninitialized when BusyBox is compiled with BB_FEATURE_LS_FILETYPES && !BB_FEATURE_LS_USERNAME.
Bug fixed by commit b273d665181
Type | UninitializedVariable |
Config | BB_FEATURE_LS_FILETYPES && !BB_FEATURE_LS_USERNAME (2nd degree) |
C-features | Structs |
Fix-in | mapping |
Location | coreutils/ |
#include <stdio.h> #include <stdlib.h> void list_single() { #ifdef BB_FEATURE_LS_FILETYPES int info; #endif #ifdef BB_FEATURE_LS_USERNAME info = 0; #endif #ifdef BB_FEATURE_LS_FILETYPES if (rand() % 2) printf("%d", info); // ERROR #endif } void showfiles() { list_single(); } int main(int argc, char** argv) { showfiles(); return 0; }
diff --git a/simple/b273d66.c b/simple/b273d66.c --- a/simple/b273d66.c +++ b/simple/b273d66.c @@ -4,7 +4,7 @@ void list_single() { -#ifdef BB_FEATURE_LS_FILETYPES +#if defined (BB_FEATURE_LS_FILETYPES) || defined (BB_FEATURE_LS_USERNAME) int info; #endif
#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { // showfiles(); #ifdef BB_FEATURE_LS_FILETYPES int info; #endif #ifdef BB_FEATURE_LS_USERNAME info = 0; #endif #ifdef BB_FEATURE_LS_FILETYPES if (rand() % 2) printf("%d", info); // ERROR #endif return 0; }
. call coreutils/ls.c:823:showfiles() .. 424:list_single(dn[i]); .. call coreutils/ls.c:524:list_single() ... [BB_FEATURE_LS_FILETYPES] 533:struct stat info; ... [BB_FEATURE_LS_USERNAME] 574:memset(&info, 0, sizeof(struct stat)); ... ERROR [BB_FEATURE_LS_FILETYPES] 645:append = append_char(info.st_mode);