From 3d56716d362d6a827c5f81029ac64c71b56a2f5c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 9 Oct 2014 13:43:32 -0500 Subject: Various bugfixes (mostly resource leaks) from Ashwini Sharma's static analysis, plus occasional tweak by me while reviewing them. --- toys/posix/comm.c | 2 +- toys/posix/cp.c | 2 +- toys/posix/id.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'toys/posix') diff --git a/toys/posix/comm.c b/toys/posix/comm.c index bbdcccef..6c726cf6 100644 --- a/toys/posix/comm.c +++ b/toys/posix/comm.c @@ -77,5 +77,5 @@ void comm_main(void) line[i] = get_line(file[i]); } - if (CFG_TOYBOX_FREE) for (i = 0; i < 2; i--) xclose(file[i]); + if (CFG_TOYBOX_FREE) for (i = 0; i < 2; i++) xclose(file[i]); } diff --git a/toys/posix/cp.c b/toys/posix/cp.c index d73b7229..fdb7c8ae 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -119,7 +119,7 @@ int cp_node(struct dirtree *try) } else { // -d is only the same as -r for symlinks, not for directories - if (S_ISLNK(try->st.st_mode) & (flags & FLAG_d)) flags |= FLAG_r; + if (S_ISLNK(try->st.st_mode) && (flags & FLAG_d)) flags |= FLAG_r; // Detect recursive copies via repeated top node (cp -R .. .) or // identical source/target (fun with hardlinks). diff --git a/toys/posix/id.c b/toys/posix/id.c index b4d9c00b..000d7b4c 100644 --- a/toys/posix/id.c +++ b/toys/posix/id.c @@ -9,7 +9,7 @@ USE_ID(NEWTOY(id, ">1nGgru[!Ggu]", TOYFLAG_BIN)) USE_GROUPS(OLDTOY(groups, id, NULL, TOYFLAG_USR|TOYFLAG_BIN)) USE_LOGNAME(OLDTOY(logname, id, ">0", TOYFLAG_BIN)) -USE_LOGNAME(OLDTOY(whoami, id, ">0", TOYFLAG_BIN)) +USE_WHOAMI(OLDTOY(whoami, id, ">0", TOYFLAG_BIN)) config ID bool "id" @@ -132,7 +132,7 @@ void do_id(char *username) void id_main(void) { - // FLAG macros can be 0 if "id" command enabled, so snapshot them here. + // FLAG macros can be 0 if "id" command not enabled, so snapshot them here. if (FLAG_u) TT.do_u = toys.optflags & FLAG_u; if (FLAG_n) TT.do_n = toys.optflags & FLAG_n; if (FLAG_G) TT.do_G = toys.optflags & FLAG_G; -- cgit v1.2.3