8210836: Build fails with warn_unused_result in openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
Summary: Read in and process the return value of pread() while dealing with the PT_INTERP segment
Reviewed-by: stuefe, jcbeyler
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c Tue Sep 18 10:43:01 2018 -0700
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c Tue Sep 18 23:20:17 2018 +0530
@@ -795,7 +795,11 @@
if (exec_php->p_filesz > BUF_SIZE) {
goto err;
}
- pread(ph->core->exec_fd, interp_name, exec_php->p_filesz, exec_php->p_offset);
+ if (pread(ph->core->exec_fd, interp_name,
+ exec_php->p_filesz, exec_php->p_offset) != exec_php->p_filesz) {
+ print_debug("Unable to read in the ELF interpreter\n");
+ goto err;
+ }
interp_name[exec_php->p_filesz] = '\0';
print_debug("ELF interpreter %s\n", interp_name);
// read interpreter segments as well