changeset 4555:13b32b29aab8

Dynamically allocate buffer using string length to avoid buffer overflow.
author andrew
date Thu, 22 Sep 2011 01:13:26 +0100
parents 2a3693537ec8
children efae8bfbb940
files src/solaris/native/java/lang/java_props_md.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/lang/java_props_md.c	Thu Sep 22 01:12:18 2011 +0100
+++ b/src/solaris/native/java/lang/java_props_md.c	Thu Sep 22 01:13:26 2011 +0100
@@ -124,7 +124,7 @@
 
 static int ParseLocale(int cat, char ** std_language, char ** std_script,
                        char ** std_country, char ** std_variant, char ** std_encoding) {
-    char temp[64];
+    char *temp;
     char *language = NULL, *country = NULL, *variant = NULL,
          *encoding = NULL;
     char *p, encoding_variant[64];
@@ -168,6 +168,7 @@
      * <country name>, <encoding name>, and <variant name> are optional.
      */
 
+    temp = (char*) malloc(strlen(lc)+1);
     strcpy(temp, lc);
 
     /* Parse the language, country, encoding, and variant from the
@@ -306,6 +307,10 @@
 #endif
     }
 
+	
+    /* Free temp */
+    free(temp);
+
     return 1;
 }