changeset 16078:3d5fa54bf734

7200500: Launcher better input validation Reviewed-by: darcy, jjh, mschoene
author ksrini
date Tue, 16 Oct 2012 10:56:25 -0700
parents 92008ab562e0
children 7252530399e2
files jdk/src/share/bin/parse_manifest.c
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/bin/parse_manifest.c	Tue Oct 16 16:38:38 2012 -0700
+++ b/jdk/src/share/bin/parse_manifest.c	Tue Oct 16 10:56:25 2012 -0700
@@ -568,9 +568,9 @@
 #ifdef O_BINARY
         | O_BINARY /* use binary mode on windows */
 #endif
-        )) == -1)
+        )) == -1) {
         return (-1);
-
+    }
     info->manifest_version = NULL;
     info->main_class = NULL;
     info->jre_version = NULL;
@@ -617,12 +617,14 @@
     zentry  entry;
     void    *data = NULL;
 
-    fd = open(jarfile, O_RDONLY
+    if ((fd = open(jarfile, O_RDONLY
 #ifdef O_BINARY
         | O_BINARY /* use binary mode on windows */
 #endif
-        );
-    if (fd != -1 && find_file(fd, &entry, filename) == 0) {
+        )) == -1) {
+        return NULL;
+    }
+    if (find_file(fd, &entry, filename) == 0) {
         data = inflate_file(fd, &entry, size);
     }
     close(fd);
@@ -664,8 +666,9 @@
 #ifdef O_BINARY
         | O_BINARY /* use binary mode on windows */
 #endif
-        )) == -1)
+        )) == -1) {
         return (-1);
+    }
 
     if (rc = find_file(fd, &entry, manifest_name) != 0) {
         close(fd);