Skip to content

Commit

Permalink
Fix: Fix parsing of colons in formatted string CPE components.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Oct 31, 2024
1 parent a905955 commit e737cfc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util/cpeutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,9 @@ 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 == ':' && c > fs_cpe && *(c - 1) != '\\');
c++)
;
}

Expand Down
16 changes: 16 additions & 0 deletions util/cpeutils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,22 @@ Ensure (cpeutils, fs_cpe_to_uri_cpe)
fs_cpe = "This is a ~:SIGNAL:~ test.";
uri_cpe = fs_cpe_to_uri_cpe (fs_cpe);
g_free (uri_cpe);

fs_cpe =
"cpe:2.3:a:9base_project:9base:1\\:6-6:*:*:*:*:*:*:*";
uri_cpe = fs_cpe_to_uri_cpe (fs_cpe);
assert_that (uri_cpe, is_equal_to_string (
"cpe:/a:9base_project:9base:1%3A6-6"));
g_free (uri_cpe);

fs_cpe =
"cpe:2.3:a:app\\:\\:cpanminus_project:app\\:\\:cpanminus:1.7000:*:*:*:*:perl:*:*";
uri_cpe = fs_cpe_to_uri_cpe (fs_cpe);
assert_that (
uri_cpe,
is_equal_to_string (
"cpe:/a:app%3A%3Acpanminus_project:app%3A%3Acpanminus:1.7000::~~~perl~~"));
g_free (uri_cpe);
}

Ensure (cpeutils, cpe_struct_match)
Expand Down

0 comments on commit e737cfc

Please sign in to comment.