aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/pending/bootchartd.c14
-rw-r--r--toys/pending/fsck.c16
-rw-r--r--toys/pending/init.c10
-rw-r--r--toys/pending/netstat.c1
4 files changed, 27 insertions, 14 deletions
diff --git a/toys/pending/bootchartd.c b/toys/pending/bootchartd.c
index cbed4ac0..72ade69c 100644
--- a/toys/pending/bootchartd.c
+++ b/toys/pending/bootchartd.c
@@ -82,7 +82,10 @@ static int dump_proc_data(FILE *fp)
char *ptr;
ssize_t len;
- if ((len = readall(fd, toybuf, sizeof(toybuf)-1)) < 0) continue;
+ if ((len = readall(fd, toybuf, sizeof(toybuf)-1)) < 0) {
+ xclose(fd);
+ continue;
+ }
toybuf[len] = '\0';
close(fd);
fputs(toybuf, fp);
@@ -226,10 +229,11 @@ static void stop_logging(char *tmp_dir, char *prog)
if ((kcmd_line_fd = open("/proc/cmdline", O_RDONLY)) != -1) {
ssize_t len;
- len = readall(kcmd_line_fd, toybuf, sizeof(toybuf)-1);
- toybuf[len] = 0;
- while (--len >= 0 && !toybuf[len]) continue;
- for (; len > 0; len--) if (toybuf[len] < ' ') toybuf[len] = ' ';
+ if ((len = readall(kcmd_line_fd, toybuf, sizeof(toybuf)-1)) > 0) {
+ toybuf[len] = 0;
+ while (--len >= 0 && !toybuf[len]) continue;
+ for (; len > 0; len--) if (toybuf[len] < ' ') toybuf[len] = ' ';
+ } else *toybuf = 0;
}
fprintf(hdr_fp, "system.kernel.options = %s", toybuf);
close(kcmd_line_fd);
diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c
index ee35c04e..723f77de 100644
--- a/toys/pending/fsck.c
+++ b/toys/pending/fsck.c
@@ -37,7 +37,7 @@ GLOBALS(
char *t_list;
struct double_list *devices;
- int *arr_flag;
+ char *arr_flag;
char **arr_type;
int negate;
int sum_status;
@@ -123,18 +123,20 @@ static void fix_tlist(void)
n++;
}
- TT.arr_flag = xzalloc((n + 1) * sizeof(char));
+ TT.arr_flag = xzalloc(n + 1);
TT.arr_type = xzalloc((n + 1) * sizeof(char *));
s = TT.t_list;
n = 0;
while ((p = strsep(&s, ","))) {
no = is_no_prefix(&p);
- if (!strcmp(p, "loop")) TT.arr_flag[n] = no ? FLAG_WITH_NO_PRFX :FLAG_WITHOUT_NO_PRFX;
- else if (!strncmp(p, "opts=", 5)) {
+ if (!strcmp(p, "loop")) {
+ TT.arr_flag[n] = no ? FLAG_WITH_NO_PRFX :FLAG_WITHOUT_NO_PRFX;
+ TT.negate = no;
+ } else if (!strncmp(p, "opts=", 5)) {
p+=5;
TT.arr_flag[n] = is_no_prefix(&p) ?FLAG_WITH_NO_PRFX :FLAG_WITHOUT_NO_PRFX;
- }
- else {
+ TT.negate = no;
+ } else {
if (!n) TT.negate = no;
if (n && TT.negate != no) error_exit("either all or none of the filesystem"
" types passed to -t must be prefixed with 'no' or '!'");
@@ -221,9 +223,9 @@ static void do_fsck(struct f_sys_info *finfo)
return;
} else {
if ((pid = fork()) < 0) {
+ perror_msg(args[0]);
for (j=0;j<i;j++) free(args[i]);
free(args);
- perror_msg(args[0]);
return;
}
if (!pid) xexec(args); //child, executes fsck.type
diff --git a/toys/pending/init.c b/toys/pending/init.c
index ca3c6cc4..529c1b9e 100644
--- a/toys/pending/init.c
+++ b/toys/pending/init.c
@@ -141,6 +141,8 @@ static void inittab_parsing(void)
line_number++;
token_count = 0;
action = 0;
+ tty_name = command = NULL;
+
while ((extracted_token = strsep(&p,":"))) {
token_count++;
switch (token_count) {
@@ -172,8 +174,12 @@ static void inittab_parsing(void)
} //while token
if (q) free(q);
- if (token_count != 4) continue;
- if (action) add_new_action(action, command, tty_name);
+ if (token_count != 4) {
+ free(tty_name);
+ free(command);
+ continue;
+ }
+ if (action) add_new_action(action, command, tty_name);
free(tty_name);
free(command);
} //while line
diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c
index 55be7726..59355638 100644
--- a/toys/pending/netstat.c
+++ b/toys/pending/netstat.c
@@ -468,6 +468,7 @@ static void get_pid_list(void)
strcpy(path + length - (sizeof("cmdline")-1), "fd");
progname = append_pathandfile(pid, (char *)get_basename(toybuf)); //e.g. progname = 2054/gnome-keyring-daemon
extract_inode(path, progname);
+ free(progname);
}//end of while.
closedir(dp);