From: Michael Tremer Date: Sat, 12 Oct 2024 14:10:40 +0000 (+0000) Subject: pty: Don't try to map empty output buffers X-Git-Tag: 0.9.30~1080 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92f6cd3678427aecb5661456647fde60b5ce2025;p=pakfire.git pty: Don't try to map empty output buffers Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pty.c b/src/libpakfire/pty.c index 21961a47e..8d8607b10 100644 --- a/src/libpakfire/pty.c +++ b/src/libpakfire/pty.c @@ -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) {