diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/other/ifconfig.c | 2 | ||||
-rw-r--r-- | toys/pending/arp.c | 5 | ||||
-rw-r--r-- | toys/pending/fsck.c | 4 | ||||
-rw-r--r-- | toys/pending/ftpget.c | 16 | ||||
-rw-r--r-- | toys/pending/modprobe.c | 3 | ||||
-rw-r--r-- | toys/pending/tar.c | 13 | ||||
-rw-r--r-- | toys/posix/uniq.c | 2 |
7 files changed, 31 insertions, 14 deletions
diff --git a/toys/other/ifconfig.c b/toys/other/ifconfig.c index a84e26ac..f5d4215e 100644 --- a/toys/other/ifconfig.c +++ b/toys/other/ifconfig.c @@ -421,7 +421,7 @@ void ifconfig_main(void) } if ((p-ptr) != count || *hw_addr) - error_exit("bad hw-addr '%s'", hw_addr ? hw_addr : ""); + error_exit("bad hw-addr '%s'", *argv); // the linux kernel's "struct sockaddr" (include/linux/socket.h in the // kernel source) only has 14 bytes of sa_data, and an infiniband address diff --git a/toys/pending/arp.c b/toys/pending/arp.c index 831facb9..1153ebc1 100644 --- a/toys/pending/arp.c +++ b/toys/pending/arp.c @@ -175,7 +175,7 @@ static int set_entry(void) flags = ATF_PERM | ATF_COM; if (toys.optargs[2]) check_flags(&flags, (toys.optargs+2)); req.arp_flags = flags; - strncpy(req.arp_dev, TT.device, sizeof(TT.device)); + strncpy(req.arp_dev, TT.device, sizeof(req.arp_dev)); xioctl(TT.sockfd, SIOCSARP, &req); if (toys.optflags & FLAG_v) xprintf("Entry set for %s\n", toys.optargs[0]); @@ -204,7 +204,7 @@ static int delete_entry(void) flags = ATF_PERM; if (toys.optargs[1]) check_flags(&flags, (toys.optargs+1)); req.arp_flags = flags; - strncpy(req.arp_dev, TT.device, sizeof(TT.device)); + strncpy(req.arp_dev, TT.device, sizeof(req.arp_dev)); xioctl(TT.sockfd, SIOCDARP, &req); if (toys.optflags & FLAG_v) xprintf("Delete entry for %s\n", toys.optargs[0]); @@ -301,6 +301,7 @@ void arp_main(void) if (CFG_TOYBOX_FREE) { free(host_ip); + free(buf); xclose(fd); } } diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c index 56dfb5df..ee35c04e 100644 --- a/toys/pending/fsck.c +++ b/toys/pending/fsck.c @@ -216,10 +216,13 @@ static void do_fsck(struct f_sys_info *finfo) } if (toys.optflags & FLAG_N) { + for (j=0;j<i;j++) free(args[i]); free(args); return; } else { if ((pid = fork()) < 0) { + for (j=0;j<i;j++) free(args[i]); + free(args); perror_msg(args[0]); return; } @@ -383,6 +386,7 @@ void fsck_main(void) if (!TT.devices || (toys.optflags & FLAG_A)) { toys.exitval = scan_all(); if (CFG_TOYBOX_FREE) goto free_all; + return; //if CFG_TOYBOX_FREE is not set, exit. } dev = TT.devices; diff --git a/toys/pending/ftpget.c b/toys/pending/ftpget.c index a68ceeb6..2a81a34a 100644 --- a/toys/pending/ftpget.c +++ b/toys/pending/ftpget.c @@ -153,21 +153,29 @@ static void verify_pasv_mode(char *r_filename) unsigned portnum; //vsftpd reply like:- "227 Entering Passive Mode (125,19,39,117,43,39)". - if (get_ftp_response("PASV", NULL) != PASSIVE_MODE) close_stream("PASV"); + if (get_ftp_response("PASV", NULL) != PASSIVE_MODE) goto close_stream; //Response is "NNN <some text> (N1,N2,N3,N4,P1,P2) garbage. //Server's IP is N1.N2.N3.N4 //Server's port for data connection is P1*256+P2. - if ((pch = strrchr(toybuf, ')'))) *pch = '\0'; - if ((pch = strrchr(toybuf, ','))) *pch = '\0'; + if (!(pch = strrchr(toybuf, ')'))) goto close_stream; + *pch = '\0'; + if (!(pch = strrchr(toybuf, ','))) goto close_stream; + *pch = '\0'; + portnum = atolx_range(pch + 1, 0, 255); - if ((pch = strrchr(toybuf, ','))) *pch = '\0'; + if (!(pch = strrchr(toybuf, ','))) goto close_stream; + *pch = '\0'; portnum = portnum + (atolx_range(pch + 1, 0, 255) * 256); setport(htons(portnum)); if (TT.isget && get_ftp_response("SIZE", r_filename) != FTPFILE_STATUS) TT.c = 0; + return; + +close_stream: + close_stream("PASV"); } /* diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c index b8ef4824..cbf929b9 100644 --- a/toys/pending/modprobe.c +++ b/toys/pending/modprobe.c @@ -199,7 +199,7 @@ static int read_line(FILE *fl, char **li) } line[len] = '\0'; *li = xstrdup(line); - if (line) free(line); + free(line); if (nxtline) free(nxtline); return len; } @@ -302,6 +302,7 @@ static int depmode_read_entry(char *cmdname) } free(line); } + fclose(fe); return ret; } diff --git a/toys/pending/tar.c b/toys/pending/tar.c index 12ee7af5..5b060c6e 100644 --- a/toys/pending/tar.c +++ b/toys/pending/tar.c @@ -84,8 +84,8 @@ static void copy_in_out(int src, int dst, off_t size) cnt = size/512 + (rem?1:0); for (i = 0; i < cnt; i++) { - rd = (((i == cnt-1) && rem)? rem:512); - if (readall(src, toybuf, rd) != rd) error_exit("short read"); + rd = (i == cnt-1 && rem) ? rem : 512; + xreadall(src, toybuf, rd); writeall(dst, toybuf, rd); } } @@ -93,11 +93,10 @@ static void copy_in_out(int src, int dst, off_t size) //convert to octal static void itoo(char *str, int len, off_t val) { - char *t, tmp[sizeof(off_t)*3+1]; //1 for NUL termination + char *t, tmp[sizeof(off_t)*3+1]; int cnt = sprintf(tmp, "%0*llo", len, val); - t = tmp; - t += (cnt - len); + t = tmp + cnt - len; if (*t == '0') t++; memcpy(str, t, len); } @@ -547,7 +546,9 @@ static char *process_extended_hdr(struct archive_handler *tar, int size) break; } } - return ((value)?xstrdup(value) : NULL); + if (value) value = xstrdup(value); + free(buf); + return value; } static void tar_skip(struct archive_handler *tar, int sz) diff --git a/toys/posix/uniq.c b/toys/posix/uniq.c index bd41d4af..3cfdb947 100644 --- a/toys/posix/uniq.c +++ b/toys/posix/uniq.c @@ -113,6 +113,8 @@ void uniq_main(void) print_line(outfile, prevline); if (CFG_TOYBOX_FREE) { + if (outfile != stdout) fclose(outfile); + if (infile != stdin) fclose(infile); free(prevline); free(thisline); } |