diff src/os/linux/vm/os_linux.cpp @ 17567:5656140324ed

8030763: Validate global memory allocation Summary: Add length checks where necessary Reviewed-by: coleenp, mschoene
author hseigel
date Thu, 13 Feb 2014 11:28:17 -0500
parents e4f478e7781b
children 3eed8712d410 364b73402247
line wrap: on
line diff
--- a/src/os/linux/vm/os_linux.cpp	Wed Feb 12 11:33:30 2014 -0800
+++ b/src/os/linux/vm/os_linux.cpp	Thu Feb 13 11:28:17 2014 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -1572,9 +1572,6 @@
   ::abort();
 }
 
-// unused on linux for now.
-void os::set_error_file(const char *logfile) {}
-
 
 // This method is a copy of JDK's sysGetLastErrorString
 // from src/solaris/hpi/src/system_md.c
@@ -2399,6 +2396,7 @@
         // determine if this is a legacy image or modules image
         // modules image doesn't have "jre" subdirectory
         len = strlen(buf);
+        assert(len < buflen, "Ran out of buffer room");
         jrelib_p = buf + len;
         snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch);
         if (0 != access(buf, F_OK)) {
@@ -2419,7 +2417,7 @@
     }
   }
 
-  strcpy(saved_jvm_path, buf);
+  strncpy(saved_jvm_path, buf, MAXPATHLEN);
 }
 
 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {