X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournalctl.c;h=86453e65c8f9b8c8e362339fba115be1ec50f5b0;hb=d636d376796ec61c1c14fa619c80d4ac62e08a19;hp=2d99ade1172fdc33ef4ffb4a6793b24c575c2906;hpb=ea18a4b57e2bb94af7b3ecb7abdaec40e9f485f0;p=elogind.git diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 2d99ade11..86453e65c 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -658,6 +658,11 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; } + if (arg_action != ACTION_SHOW && optind < argc) { + log_error("Extraneous arguments starting with '%s'", argv[optind]); + return -EINVAL; + } + return 1; } @@ -727,7 +732,7 @@ static int add_matches(sd_journal *j, char **args) { t = strappend("_COMM=", comm); /* Append _EXE only if the interpreter is not a link. - Otherwise it might be outdated often. */ + Otherwise, it might be outdated often. */ if (lstat(interpreter, &st) == 0 && !S_ISLNK(st.st_mode)) { t2 = strappend("_EXE=", interpreter); @@ -1285,8 +1290,8 @@ static int setup_keys(void) { n = now(CLOCK_REALTIME); n /= arg_interval; - close_nointr_nofail(fd); - fd = mkostemp(k, O_WRONLY|O_CLOEXEC|O_NOCTTY); + safe_close(fd); + fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC); if (fd < 0) { log_error("Failed to open %s: %m", k); r = -errno; @@ -1384,8 +1389,7 @@ static int setup_keys(void) { r = 0; finish: - if (fd >= 0) - close_nointr_nofail(fd); + safe_close(fd); if (k) { unlink(k); @@ -1651,7 +1655,7 @@ int main(int argc, char *argv[]) { } if (arg_action == ACTION_DISK_USAGE) { - uint64_t bytes; + uint64_t bytes = 0; char sbytes[FORMAT_BYTES_MAX]; r = sd_journal_get_usage(j, &bytes); @@ -1933,5 +1937,7 @@ int main(int argc, char *argv[]) { finish: pager_close(); + strv_free(arg_file); + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }