On 16 March 2017 at 06:10, Tapani Pälli <tapani.pa...@intel.com> wrote: > According to dl_iterate_phdr man page first object visited is the > main program where dlpi_name is an empty string. This fixes segfault > on Android when using build-id as identifier. > > Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> > --- > src/util/build_id.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/util/build_id.c b/src/util/build_id.c > index c53e71d..797ea22 100644 > --- a/src/util/build_id.c > +++ b/src/util/build_id.c > @@ -55,6 +55,12 @@ build_id_find_nhdr_callback(struct dl_phdr_info *info, > size_t size, void *data_) > { > struct callback_data *data = data_; > > + /* The first object visited by callback is the main program. > + * For the main program, the dlpi_name field will be an empty string. > + */ > + if (info->dlpi_name == NULL) > + return 0; > + > char *ptr = strstr(info->dlpi_name, data->filename); Current behaviour was OK on Linux platforms since Glibc (some versions at least) provide a non-NULL empty string, which would not crash in the strstr below.
That said, the fix the the correct thing to do and is Fixes: d4fa083e11f ("util: Add utility build-id code.") Reviewed-by: Emil Velikov <emil.veli...@collabora.com> -Emil _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev