aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-10-09 13:43:32 -0500
committerRob Landley <rob@landley.net>2014-10-09 13:43:32 -0500
commit3d56716d362d6a827c5f81029ac64c71b56a2f5c (patch)
tree93377ffa6621214916c82b0985483e4d13822336 /toys/other
parent7196d758a0728bd43451f869eb85528b6cd20bea (diff)
downloadtoybox-3d56716d362d6a827c5f81029ac64c71b56a2f5c.tar.gz
Various bugfixes (mostly resource leaks) from Ashwini Sharma's static analysis, plus occasional tweak by me while reviewing them.
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/ifconfig.c2
-rw-r--r--toys/other/insmod.c10
-rw-r--r--toys/other/losetup.c2
3 files changed, 9 insertions, 5 deletions
diff --git a/toys/other/ifconfig.c b/toys/other/ifconfig.c
index f5d4215e..4d5c74d0 100644
--- a/toys/other/ifconfig.c
+++ b/toys/other/ifconfig.c
@@ -6,7 +6,7 @@
*
* Not in SUSv4.
-USE_IFCONFIG(NEWTOY(ifconfig, "?a", TOYFLAG_BIN))
+USE_IFCONFIG(NEWTOY(ifconfig, "^?a", TOYFLAG_BIN))
config IFCONFIG
bool "ifconfig"
diff --git a/toys/other/insmod.c b/toys/other/insmod.c
index 8aa959a9..81721a31 100644
--- a/toys/other/insmod.c
+++ b/toys/other/insmod.c
@@ -22,7 +22,7 @@ void insmod_main(void)
{
char * buf = NULL;
int len, res, i;
- int fd = xopen(toys.optargs[0], O_RDONLY);
+ int fd = xopen(*toys.optargs, O_RDONLY);
len = fdlength(fd);
buf = xmalloc(len);
@@ -30,13 +30,17 @@ void insmod_main(void)
i = 1;
while(toys.optargs[i] &&
- strlen(toybuf) + strlen(toys.optargs[i]) + 2 < sizeof(toybuf)) {
+ strlen(toybuf) + strlen(toys.optargs[i]) + 2 < sizeof(toybuf))
+ {
strcat(toybuf, toys.optargs[i++]);
strcat(toybuf, " ");
}
res = init_module(buf, len, toybuf);
- if (CFG_TOYBOX_FREE && buf != toybuf) free(buf);
+ if (CFG_TOYBOX_FREE) {
+ if (buf != toybuf) free(buf);
+ close(fd);
+ }
if (res) perror_exit("failed to load %s", toys.optargs[0]);
}
diff --git a/toys/other/losetup.c b/toys/other/losetup.c
index e96a125d..e3094ef0 100644
--- a/toys/other/losetup.c
+++ b/toys/other/losetup.c
@@ -86,7 +86,7 @@ static void loopback_setup(char *device, char *file)
// Stat the loop device to see if there's a current association.
memset(loop, 0, sizeof(struct loop_info64));
if (-1 == lfd || ioctl(lfd, LOOP_GET_STATUS64, loop)) {
- if (errno == ENXIO && (flags & (FLAG_a|FLAG_j))) return;
+ if (errno == ENXIO && (flags & (FLAG_a|FLAG_j))) goto done;
if (errno != ENXIO || !file) {
perror_msg("%s", device ? device : "-f");
goto done;