am 4a72b306: Merge "fix possible buffer overrun and memory leak"
* commit '4a72b3064cecc85c56b8d75bb4a2d9fedbf76ec8': fix possible buffer overrun and memory leak
This commit is contained in:
@@ -943,13 +943,20 @@ static jboolean android_os_BinderProxy_isBinderAlive(JNIEnv* env, jobject obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int getprocname(pid_t pid, char *buf, size_t len) {
|
static int getprocname(pid_t pid, char *buf, size_t len) {
|
||||||
char filename[20];
|
char filename[32];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
sprintf(filename, "/proc/%d/cmdline", pid);
|
snprintf(filename, sizeof(filename), "/proc/%d/cmdline", pid);
|
||||||
f = fopen(filename, "r");
|
f = fopen(filename, "r");
|
||||||
if (!f) { *buf = '\0'; return 1; }
|
if (!f) {
|
||||||
if (!fgets(buf, len, f)) { *buf = '\0'; return 2; }
|
*buf = '\0';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!fgets(buf, len, f)) {
|
||||||
|
*buf = '\0';
|
||||||
|
fclose(f);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user