audio/al: replace strcat with strlcat

Comment from golang.org/cl/6642. As bionic (surprisingly) has strlcat,
using it instead of strncat. If you're not familiar with the l-variants,
see http://www.sudo.ws/todd/papers/strlcpy.html

Change-Id: I69958ee99917903f9d10dda0ec99111c4793db71
Reviewed-on: https://go-review.googlesource.com/7011
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw 2015-03-06 08:05:58 -05:00
parent 269086b6fe
commit c30f429855
1 changed files with 3 additions and 2 deletions

View File

@ -9,6 +9,7 @@ package al
#include <android/log.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <jni.h>
#include <limits.h>
@ -42,8 +43,8 @@ void* al_init(void* vm, void* context) {
const char *cpackage_name = (*env)->GetStringUTFChars(env, package_name, 0);
char lib_path[PATH_MAX] = "/data/data/";
strcat(lib_path, cpackage_name);
strcat(lib_path, "/lib/libopenal.so");
strlcat(lib_path, cpackage_name, sizeof(lib_path));
strlcat(lib_path, "/lib/libopenal.so", sizeof(lib_path));
void* handle = dlopen(lib_path, RTLD_LAZY);
(*env)->ReleaseStringUTFChars(env, package_name, cpackage_name);
if (!handle) {