]> git.ipfire.org Git - pakfire.git/commitdiff
pty: Don't try to map empty output buffers
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:10:40 +0000 (14:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:10:40 +0000 (14:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pty.c

index 21961a47e3516d05e48a4f1ee950d106c8396021..8d8607b108bc940935d3f1214d1792c3f189d587 100644 (file)
@@ -122,6 +122,10 @@ static int pakfire_pty_store_output(struct pakfire_pty* pty) {
 
        CTX_DEBUG(pty->ctx, "Read %jd byte(s) of output\n", buffer.st_size);
 
+       // Don't try to map an empty buffer
+       if (!buffer.st_size)
+               return 0;
+
        // Map the output into memory
        pty->output.iov_base = mmap(NULL, buffer.st_size, PROT_READ, MAP_SHARED, pty->stdout.fd, 0);
        if (pty->output.iov_base == MAP_FAILED) {