]> granicus.if.org Git - php/commitdiff
Don't assume that Java byte arrays are null terminated.
authorSam Ruby <rubys@php.net>
Sat, 22 Jul 2000 12:40:49 +0000 (12:40 +0000)
committerSam Ruby <rubys@php.net>
Sat, 22 Jul 2000 12:40:49 +0000 (12:40 +0000)
ext/java/java.c
ext/rpc/java/java.c

index 701640b0e53f7ad88d2358ad307f2425b1c75a57..eac474530222a81f7816319cef071f954868a569 100644 (file)
@@ -653,7 +653,8 @@ JNIEXPORT void JNICALL Java_net_php_reflect_setResultFromString
   presult->type=IS_STRING;
   presult->value.str.len=(*jenv)->GetArrayLength(jenv, jvalue);
   presult->value.str.val=emalloc(presult->value.str.len+1);
-  strcpy(presult->value.str.val, value);
+  memcpy(presult->value.str.val, value, presult->value.str.len);
+  presult->value.str.val[presult->value.str.len]=0;
   if (isCopy) (*jenv)->ReleaseByteArrayElements(jenv, jvalue, value, 0);
 }
 
index 701640b0e53f7ad88d2358ad307f2425b1c75a57..eac474530222a81f7816319cef071f954868a569 100644 (file)
@@ -653,7 +653,8 @@ JNIEXPORT void JNICALL Java_net_php_reflect_setResultFromString
   presult->type=IS_STRING;
   presult->value.str.len=(*jenv)->GetArrayLength(jenv, jvalue);
   presult->value.str.val=emalloc(presult->value.str.len+1);
-  strcpy(presult->value.str.val, value);
+  memcpy(presult->value.str.val, value, presult->value.str.len);
+  presult->value.str.val[presult->value.str.len]=0;
   if (isCopy) (*jenv)->ReleaseByteArrayElements(jenv, jvalue, value, 0);
 }