diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2014-10-29 14:08:21 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2014-10-29 14:08:21 +0000 |
commit | 8662fda2e966f88c3423feeb5ea49b10ac0305bd (patch) | |
tree | e7e15c78f5c608698e2f531958d0af6a22550943 | |
parent | fe79ff1a7cf43f76ee0680c2d86c8f74f5dedfba (diff) | |
download | illumos-joyent-8662fda2e966f88c3423feeb5ea49b10ac0305bd.tar.gz |
OS-3486 lxbrand mremap fails
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/mem.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/mem.c b/usr/src/lib/brand/lx/lx_brand/common/mem.c index c44c0394d7..a7deccaa26 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/mem.c +++ b/usr/src/lib/brand/lx/lx_brand/common/mem.c @@ -256,10 +256,10 @@ long lx_remap(uintptr_t old_address, uintptr_t old_size, uintptr_t new_size, uintptr_t flags, uintptr_t new_address) { - int prot = 0, oflags, mflags = 0, fd; + int prot = 0, oflags, mflags = 0, len, fd; prmap_t map; uintptr_t rval; - char path[256], buf[MAXPATHLEN]; + char path[256], buf[MAXPATHLEN + 1]; /* * The kernel doesn't actually support mremap(), so to emulate it, @@ -322,12 +322,14 @@ lx_remap(uintptr_t old_address, uintptr_t old_size, (void) snprintf(path, sizeof (path), "/native/proc/self/path/%s", map.pr_mapname); - if (readlink(path, buf, sizeof (buf) - 1) == -1) { + if ((len = readlink(path, buf, sizeof (buf))) == -1 || + len == sizeof (buf)) { /* * If we failed to read the link, the path might not exist. */ return (-EINVAL); } + buf[len] = '\0'; if ((fd = open(buf, oflags)) == -1) { /* |