aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidvfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/androidvfs.c')
-rw-r--r--src/androidvfs.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/androidvfs.c b/src/androidvfs.c
index 78f6b6da6a8..d618e351204 100644
--- a/src/androidvfs.c
+++ b/src/androidvfs.c
@@ -1018,8 +1018,8 @@ android_extract_long (char *pointer)
1018static const char * 1018static const char *
1019android_scan_directory_tree (char *file, size_t *limit_return) 1019android_scan_directory_tree (char *file, size_t *limit_return)
1020{ 1020{
1021 char *token, *saveptr, *copy, *copy1, *start, *max, *limit; 1021 char *token, *saveptr, *copy, *start, *max, *limit;
1022 size_t token_length, ntokens, i; 1022 size_t token_length, ntokens, i, len;
1023 char *tokens[10]; 1023 char *tokens[10];
1024 1024
1025 USE_SAFE_ALLOCA; 1025 USE_SAFE_ALLOCA;
@@ -1031,11 +1031,14 @@ android_scan_directory_tree (char *file, size_t *limit_return)
1031 limit = (char *) directory_tree + directory_tree_size; 1031 limit = (char *) directory_tree + directory_tree_size;
1032 1032
1033 /* Now, split `file' into tokens, with the delimiter being the file 1033 /* Now, split `file' into tokens, with the delimiter being the file
1034 name separator. Look for the file and seek past it. */ 1034 name separator. Look for the file and seek past it. Create a copy
1035 of FILE for the enjoyment of `strtok_r'. */
1035 1036
1036 ntokens = 0; 1037 ntokens = 0;
1037 saveptr = NULL; 1038 saveptr = NULL;
1038 copy = copy1 = xstrdup (file); 1039 len = strlen (file) + 1;
1040 copy = SAFE_ALLOCA (len);
1041 memcpy (copy, file, len);
1039 memset (tokens, 0, sizeof tokens); 1042 memset (tokens, 0, sizeof tokens);
1040 1043
1041 while ((token = strtok_r (copy, "/", &saveptr))) 1044 while ((token = strtok_r (copy, "/", &saveptr)))
@@ -1044,19 +1047,14 @@ android_scan_directory_tree (char *file, size_t *limit_return)
1044 1047
1045 /* Make sure ntokens is within bounds. */ 1048 /* Make sure ntokens is within bounds. */
1046 if (ntokens == ARRAYELTS (tokens)) 1049 if (ntokens == ARRAYELTS (tokens))
1047 { 1050 goto fail;
1048 xfree (copy1);
1049 goto fail;
1050 }
1051 1051
1052 tokens[ntokens] = SAFE_ALLOCA (strlen (token) + 1); 1052 len = strlen (token) + 1;
1053 memcpy (tokens[ntokens], token, strlen (token) + 1); 1053 tokens[ntokens] = SAFE_ALLOCA (len);
1054 memcpy (tokens[ntokens], token, len);
1054 ntokens++; 1055 ntokens++;
1055 } 1056 }
1056 1057
1057 /* Free the copy created for strtok_r. */
1058 xfree (copy1);
1059
1060 /* If there are no tokens, just return the start of the directory 1058 /* If there are no tokens, just return the start of the directory
1061 tree. */ 1059 tree. */
1062 1060
@@ -6319,6 +6317,8 @@ static sem_t saf_completion_sem;
6319JNIEXPORT jint JNICALL 6317JNIEXPORT jint JNICALL
6320NATIVE_NAME (safSyncAndReadInput) (JNIEnv *env, jobject object) 6318NATIVE_NAME (safSyncAndReadInput) (JNIEnv *env, jobject object)
6321{ 6319{
6320 JNI_STACK_ALIGNMENT_PROLOGUE;
6321
6322 while (sem_wait (&saf_completion_sem) < 0) 6322 while (sem_wait (&saf_completion_sem) < 0)
6323 { 6323 {
6324 if (input_blocked_p ()) 6324 if (input_blocked_p ())
@@ -6340,6 +6340,8 @@ NATIVE_NAME (safSyncAndReadInput) (JNIEnv *env, jobject object)
6340JNIEXPORT void JNICALL 6340JNIEXPORT void JNICALL
6341NATIVE_NAME (safSync) (JNIEnv *env, jobject object) 6341NATIVE_NAME (safSync) (JNIEnv *env, jobject object)
6342{ 6342{
6343 JNI_STACK_ALIGNMENT_PROLOGUE;
6344
6343 while (sem_wait (&saf_completion_sem) < 0) 6345 while (sem_wait (&saf_completion_sem) < 0)
6344 process_pending_signals (); 6346 process_pending_signals ();
6345} 6347}
@@ -6347,12 +6349,16 @@ NATIVE_NAME (safSync) (JNIEnv *env, jobject object)
6347JNIEXPORT void JNICALL 6349JNIEXPORT void JNICALL
6348NATIVE_NAME (safPostRequest) (JNIEnv *env, jobject object) 6350NATIVE_NAME (safPostRequest) (JNIEnv *env, jobject object)
6349{ 6351{
6352 JNI_STACK_ALIGNMENT_PROLOGUE;
6353
6350 sem_post (&saf_completion_sem); 6354 sem_post (&saf_completion_sem);
6351} 6355}
6352 6356
6353JNIEXPORT jboolean JNICALL 6357JNIEXPORT jboolean JNICALL
6354NATIVE_NAME (ftruncate) (JNIEnv *env, jobject object, jint fd) 6358NATIVE_NAME (ftruncate) (JNIEnv *env, jobject object, jint fd)
6355{ 6359{
6360 JNI_STACK_ALIGNMENT_PROLOGUE;
6361
6356 if (ftruncate (fd, 0) < 0) 6362 if (ftruncate (fd, 0) < 0)
6357 return false; 6363 return false;
6358 6364