aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-11-22 12:08:21 +0100
committerDmitry Vyukov <dvyukov@google.com>2022-11-23 09:09:39 +0100
commit1c50689b39eb028d91a28951b8300b7970a2aca5 (patch)
tree84cd6ab7f5fb0d87ed334a59ad3949df35afb5ab /pkg/csource
parentcaddc6cbcef9933a4539a06714df006e0c5ac7b2 (diff)
executor: fix puff_zlib_to_file signature
In executor code we commonly use the syscall interface for functions: return -1 on erorr and set errno. Use this interface for puff_zlib_to_file.
Diffstat (limited to 'pkg/csource')
-rw-r--r--pkg/csource/generated.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 13ccfa259..9e2fa9155 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -6659,6 +6659,7 @@ static int puff(
//% END CODE DERIVED FROM puff.{c,h}
+#include <errno.h>
#include <sys/mman.h>
#define ZLIB_HEADER_WIDTH 2
@@ -6668,23 +6669,23 @@ static int puff_zlib_to_file(
int dest_fd,
unsigned long destlen)
{
- if (sourcelen < ZLIB_HEADER_WIDTH)
- return -12;
+ if (sourcelen < ZLIB_HEADER_WIDTH) {
+ errno = EMSGSIZE;
+ return -1;
+ }
source += ZLIB_HEADER_WIDTH;
sourcelen -= ZLIB_HEADER_WIDTH;
void* ret = mmap(0, destlen, PROT_WRITE | PROT_READ, MAP_SHARED, dest_fd, 0);
if (ret == MAP_FAILED)
- return -13;
+ return -1;
unsigned char* dest = (unsigned char*)ret;
unsigned long destlen_copy = destlen;
int err = puff(dest, &destlen_copy, source, &sourcelen);
- if (err)
- return err;
- err = munmap(dest, destlen);
- if (err)
- return -14;
-
- return 0;
+ if (err) {
+ errno = -err;
+ return -1;
+ }
+ return munmap(dest, destlen);
}
#include <errno.h>
@@ -6706,9 +6707,9 @@ static int setup_loop_device(long unsigned size, long unsigned compressed_size,
goto error_close_memfd;
}
- err = puff_zlib_to_file(data, compressed_size, memfd, size);
- if (err) {
- debug("setup_loop_device: could not decompress data: %d\n", err);
+ if (puff_zlib_to_file(data, compressed_size, memfd, size)) {
+ err = errno;
+ debug("setup_loop_device: could not decompress data: %d\n", errno);
goto error_close_memfd;
}