8210836: Build fails with warn_unused_result in openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
authorjgeorge
Tue, 18 Sep 2018 23:20:17 +0530
changeset 51788 c0f9161f591e
parent 51787 ba51515b64e5
child 51789 0535b5a54b83
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
src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
--- 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