X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournalctl.c;h=5a59a3ac83f41ee71c8d1cb84c60d664ec3fe896;hb=7de80bfe2e61d5818601ccfddbadad3b7703ed70;hp=7aedbf0c5793c10fad51af44f0d0912e8dbcdcc3;hpb=6d314eca15f6cbda38d82774b210f784d3d4f52a;p=elogind.git diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 7aedbf0c5..5a59a3ac8 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -746,11 +746,17 @@ static int add_matches(sd_journal *j, char **args) { } } else t = strappend("_EXE=", path); - } else if (S_ISCHR(st.st_mode)) - asprintf(&t, "_KERNEL_DEVICE=c%u:%u", major(st.st_rdev), minor(st.st_rdev)); - else if (S_ISBLK(st.st_mode)) - asprintf(&t, "_KERNEL_DEVICE=b%u:%u", major(st.st_rdev), minor(st.st_rdev)); - else { + } else if (S_ISCHR(st.st_mode)) { + if (asprintf(&t, "_KERNEL_DEVICE=c%u:%u", + major(st.st_rdev), + minor(st.st_rdev)) < 0) + return -ENOMEM; + } else if (S_ISBLK(st.st_mode)) { + if (asprintf(&t, "_KERNEL_DEVICE=b%u:%u", + major(st.st_rdev), + minor(st.st_rdev)) < 0) + return -ENOMEM; + } else { log_error("File is neither a device node, nor regular file, nor executable: %s", *i); return -EINVAL; }