On Sat, May 17, 2014 at 01:14:47AM +0200, Stephane Eranian wrote:
> From: Michael Lentine <mlent...@google.com>
> 
> This patch automtically adjusts the path of MMAP records
> associated with Android system libraries. It enables running
> perf reporting tools directly on the Android system natively.

could the changelog have more info about the lib name changes?

SNIP

> +
> +     if (!strncmp(filename, "/data/app-lib", 13)) {
> +             char *apk_path;
> +
> +             if (!app_abi_length)
> +                     return false;
> +
> +             new_length = 7 + app_abi_length + lib_length;
> +
> +             apk_path = getenv("APK_PATH");
> +             if(apk_path) {
> +                     snprintf(*newfilename, new_length + strlen(apk_path) + 
> 1,
> +                              "%s/libs/%s/%s", apk_path, app_abi, libname);
> +             } else {
> +                     snprintf(*newfilename, new_length,
> +                              "libs/%s/%s", app_abi, libname);
> +             }

missing check for overflowing PATH_MAX for 'new_length' and 'new_length + 
strlen(apk_path) + 1'

> +             return true;
> +     }
> +
> +     if (!strncmp(filename, "/system/lib/", 11)) {
> +             char *ndk, *app;
> +             const char *arch;
> +             size_t ndk_length;
> +             size_t app_length;
> +
> +             ndk = getenv("NDK_ROOT");
> +             app = getenv("APP_PLATFORM");
> +
> +             if (!(ndk && app))
> +                     return false;
> +
> +             ndk_length = strlen(ndk);
> +             app_length = strlen(app);
> +
> +             if (!(ndk_length && app_length && app_abi_length))
> +                     return false;
> +
> +             arch = !strncmp(app_abi, "arm", 3) ? "arm" :
> +                    !strncmp(app_abi, "mips", 4) ? "mips" :
> +                    !strncmp(app_abi, "x86", 3) ? "x86" : NULL;
> +
> +             if (!arch)
> +                     return false;
> +
> +             new_length = 27 + ndk_length +
> +                          app_length + lib_length
> +                        + strlen(arch);

missing check for overflowing PATH_MAX for 'new_length'

> +
> +             snprintf(*newfilename, new_length,
> +                     "%s/platforms/%s/arch-%s/usr/lib/%s",
> +                     ndk, app, arch, libname);
> +
> +             return true;
> +     }
> +     return false;
> +}
> +

SNIP

> +             if (android) {
> +                     char *newfilename_ptr = newfilename;
> +                     if (replace_android_lib(filename, &newfilename_ptr))
> +                             filename = newfilename;

Why is the newfilename_ptr needed? We could pass newfilename directly
to replace_android_lib function

                if (replace_android_lib(filename, newfilename))
                        filename = newfilename;

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to