From: Housam Alamour Date: Thu, 12 Oct 2023 20:40:43 +0000 (-0400) Subject: Fix for case where empty string is input for .process($archive) argument X-Git-Tag: release-5.0a~29 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=d28ab93553055ea9c3ca890971d552570f6dc4f7;p=systemtap.git Fix for case where empty string is input for .process($archive) argument --- diff --git a/tapset-debuginfod.cxx b/tapset-debuginfod.cxx index 1251a967b..8522dda75 100644 --- a/tapset-debuginfod.cxx +++ b/tapset-debuginfod.cxx @@ -10,6 +10,7 @@ #include "tapsets.h" #include "translate.h" #include "util.h" +#include "fnmatch.h" #if defined(HAVE_LIBDEBUGINFOD) && defined(HAVE_JSON_C) @@ -25,7 +26,7 @@ static const string TOK_PACKAGE("package"); static const string TOK_PROCESS("process"); void -get_buildids(string package, string process_path, set& buildids){ +get_buildids(bool has_package, string package, string process_path, set& buildids){ static unique_ptr client (debuginfod_begin(), &debuginfod_end); @@ -64,13 +65,13 @@ get_buildids(string package, string process_path, set& buildids json_object_object_get_ex(file_metadata, "type", &json_field) && 0 == strcmp(json_object_get_string(json_field), "executable")) { // Skip the buildid if the archive file name does not contain the requested package string - if(!package.empty()) + if(has_package) { json_object_object_get_ex(file_metadata, "archive", &json_field); string path = json_object_get_string(json_field); string base_filename = path.substr(path.find_last_of("/\\") + 1); - if(json_object_object_get_ex(file_metadata, "archive", &json_field) && - std::string::npos == base_filename.find(package.c_str())) + if(json_object_object_get_ex(file_metadata, "archive", &json_field) && + 0 != fnmatch(package.c_str(), base_filename.c_str(), 0)) continue; } @@ -120,14 +121,14 @@ debuginfod_builder::build(systemtap_session & sess, probe * base, interned_string process_path; bool has_debuginfod = has_null_param (parameters, TOK_DEBUGINFOD); bool has_process = get_param (parameters, TOK_PROCESS, process_path); - get_param (parameters, TOK_PACKAGE, package); + bool has_package = get_param (parameters, TOK_PACKAGE, package); if(!has_debuginfod || !has_process) throw SEMANTIC_ERROR(_("the probe must be of the form debuginfod.[.package(\"foobar\")]process(\"foo/bar\").**{...}")); // The matching buildids from the packages/debuginfod set buildids; - get_buildids(package, process_path, buildids); + get_buildids(has_package, package, process_path, buildids); probe *base_p = new probe(base, location); probe_point *base_pp = base_p->locations[0]; @@ -159,10 +160,6 @@ debuginfod_builder::build(systemtap_session & sess, probe * base, vector results; derive_probes(sess, base_p, results, false, true); - if(results.size() < buildids.size()) - throw SEMANTIC_ERROR (_F("at least %d probes should be derived but only %d were", - (int)buildids.size(), (int)results.size())); - finished_results.insert(finished_results.end(), results.begin(), results.end()); }