< prev index next >
src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c
Print this page
rev 13166 : read/write APIs in class os shall return ssize_t
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -1248,15 +1248,25 @@
if (add_map_info(ph, ph->core->exec_fd, exec_php->p_offset, exec_php->p_vaddr, exec_php->p_filesz) == NULL) goto err;
}
break;
}
- // read the interpreter and it's segments
+ // read the interpreter and its segments
case PT_INTERP: {
- char interp_name[BUF_SIZE];
+ ssize_t res;
+ char interp_name[BUF_SIZE + 1];
- pread(ph->core->exec_fd, interp_name, MIN(exec_php->p_filesz, BUF_SIZE), exec_php->p_offset);
+ // BUF_SIZE is PATH_MAX + NAME_MAX + 1.
+ if (exec_php->p_filesz > BUF_SIZE) {
+ goto err;
+ }
+ res = pread(ph->core->exec_fd, interp_name, exec_php->p_filesz, exec_php->p_offset);
+ if (res < 0) {
+ print_debug("couldn't read ELF interpreter name\n");
+ goto err;
+ }
+ interp_name[exec_php->p_filesz] = '\0';
print_debug("ELF interpreter %s\n", interp_name);
// read interpreter segments as well
if ((ph->core->interp_fd = pathmap_open(interp_name)) < 0) {
print_debug("can't open runtime loader\n");
goto err;
< prev index next >