[Libosinfo] [PATCH libosinfo 2/5] db: Force anchored patterns when matching regex

Fabiano Fidêncio fidencio at redhat.com
Fri Sep 7 19:18:56 UTC 2018


Without forcing anchored patterns some matches may be completely wrong
as "(J_)?CENN?A_X64FREV" (volume-id for Windows 10) that could be taken
as a match for "HRM_CENNA_X64FREV" (volume-id of a Windows 8 ISO).

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/osinfo_db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index fa14c6d..f4b3a8c 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -37,7 +37,7 @@ G_DEFINE_TYPE(OsinfoDb, osinfo_db, G_TYPE_OBJECT);
 #define match_regex(pattern, str)                                       \
     (((pattern) == NULL) ||                                             \
      (((str) != NULL) &&                                                \
-      g_regex_match_simple((pattern), (str), 0, 0)))
+      g_regex_match_simple((pattern), (str), 0, G_REGEX_MATCH_ANCHORED)))
 
 static gchar *get_raw_lang(const char *volume_id, const gchar *regex_str)
 {
-- 
2.17.1




More information about the Libosinfo mailing list