From 6c7a5b92bdfe68e847d371cc41f6655df3ef1ba5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 30 Jun 2021 11:25:07 +0000 Subject: bugfix: offset in cdb mmap An offset of -1 worked because most OSes treat it as 0, but DS9k would fail on it. Signed-off-by: Laurent Bercot --- src/libstddjb/cdb_init.c | 2 +- src/libstddjb/cdb_mapfile.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstddjb') diff --git a/src/libstddjb/cdb_init.c b/src/libstddjb/cdb_init.c index 2a1ffb3..8b56c1a 100644 --- a/src/libstddjb/cdb_init.c +++ b/src/libstddjb/cdb_init.c @@ -15,7 +15,7 @@ int cdb_init (struct cdb *c, int fd) char *map ; if (fstat(fd, &st) < 0) return -1 ; if (st.st_size > UINT32_MAX) return (errno = EOVERFLOW, -1) ; - map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, -1) ; + map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (map == MAP_FAILED) return -1 ; c->map = map ; c->size = st.st_size ; diff --git a/src/libstddjb/cdb_mapfile.c b/src/libstddjb/cdb_mapfile.c index f2c56bb..b31f1e6 100644 --- a/src/libstddjb/cdb_mapfile.c +++ b/src/libstddjb/cdb_mapfile.c @@ -5,9 +5,9 @@ int cdb_mapfile (struct cdb *c, char const *file) { - int fd = open_readb(file) ; + int fd = openc_read(file) ; if (fd < 0) return 0 ; - if (!cdb_init_map(c, fd, 1)) + if (cdb_init(c, fd) == -1) { fd_close(fd) ; return 0 ; -- cgit v1.2.3