Skip to content

Commit

Permalink
Fix: Fixed the problem with escaped colons in fs CPEs.
Browse files Browse the repository at this point in the history
There was a problem, when a formatted string CPE contained an
escaped colon (e. g.) in the version. This problem is fixed now.
  • Loading branch information
jhelmold committed Oct 24, 2024
1 parent a905955 commit 0fb31ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
9 changes: 7 additions & 2 deletions util/cpeutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,13 @@ get_fs_component (const char *fs_cpe, int index)
component_end = component_start;
else
{
for (c = component_start; *c != '\0' && *c != ':'; c++)
;
for (c = component_start; *c != '\0'; c++)
{
if (*c == ':' && c == component_start)
break;
else if (c > component_start && *c == ':' && *(c - 1) != '\\')
break;
}
}

component_end = c;
Expand Down
18 changes: 18 additions & 0 deletions util/cpeutils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ Ensure (cpeutils, fs_cpe_to_uri_cpe)
"cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win2003~x64~"));
g_free (uri_cpe);

fs_cpe =
"cpe:2.3:a:hp:insight_diagnostics:7\\:4.0.1570:-:*:*:online:win2003:x64:*";
uri_cpe = fs_cpe_to_uri_cpe (fs_cpe);
assert_that (
uri_cpe,
is_equal_to_string (
"cpe:/a:hp:insight_diagnostics:7%3A4.0.1570:-:~~online~win2003~x64~"));
g_free (uri_cpe);

fs_cpe =
"cpe:2.3:a:hp:insight_diagnostics:7.4.0.1570:-:*:*:online:win\\:2003:x64:*";
uri_cpe = fs_cpe_to_uri_cpe (fs_cpe);
assert_that (
uri_cpe,
is_equal_to_string (
"cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win%3A2003~x64~"));
g_free (uri_cpe);

fs_cpe = "This is a ~:SIGNAL:~ test.";
uri_cpe = fs_cpe_to_uri_cpe (fs_cpe);
g_free (uri_cpe);
Expand Down

0 comments on commit 0fb31ce

Please sign in to comment.