From c7a9c24d18d5d25b685449cb9138b29b8faab2fa Mon Sep 17 00:00:00 2001 From: mscasso-scanoss Date: Wed, 27 May 2026 16:23:15 +0200 Subject: [PATCH 1/2] Hotfix: bug processing file extensions --- src/ignorelist.c | 7 +++++-- src/match.c | 27 ++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/ignorelist.c b/src/ignorelist.c index 2fdf920..5ad11bf 100644 --- a/src/ignorelist.c +++ b/src/ignorelist.c @@ -46,10 +46,13 @@ char *extension(char *path) { char *dot = strrchr(path, '.'); char *slash = strrchr(path, '/'); + if (!slash) slash = path; - if (!dot && !slash) return NULL; + /* No dot, or the last dot belongs to a parent directory (e.g. "a.b/file"): + the file has no extension. Returning the basename here (as the previous + implementation did) wrongly treated a plain filename as an extension. */ + if (!dot) return NULL; if (dot > slash) return dot + 1; - if (slash != path) return slash + 1; return NULL; } diff --git a/src/match.c b/src/match.c index c20d927..6ae56c7 100644 --- a/src/match.c +++ b/src/match.c @@ -301,26 +301,19 @@ int compare_file_extension(component_data_t *a, component_data_t *b) char *ext_a = extension(a->file); char *ext_b = extension(b->file); - if (!ext_a && ext_b) - return 1; - - if (ext_a && !ext_b) - return -1; - - if (!ext_a && !ext_b) + /* A candidate is preferred only when its extension actually matches the + scanned file's extension. The mere presence/absence of an extension is + not a valid criterion: doing so would prefer any extended path over a + plain filename even when neither matches the scanned file. */ + bool match_a = ext_a && !strcmp(ext_a, ext_file); + bool match_b = ext_b && !strcmp(ext_b, ext_file); + + if (match_a == match_b) return 0; - - int result_a = strcmp(ext_a, ext_file); - int result_b = strcmp(ext_b, ext_file); - - if (result_a == result_b) - return 0; - else if (!result_a) + else if (match_a) return -1; - else if (!result_b) + else return 1; - - return 0; } /** From d6cbf0ac1aa295b9d97e449b04408871960108c8 Mon Sep 17 00:00:00 2001 From: mscasso-scanoss Date: Wed, 27 May 2026 16:24:48 +0200 Subject: [PATCH 2/2] update version --- inc/scanoss.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/scanoss.h b/inc/scanoss.h index 8985597..1f4a2be 100644 --- a/inc/scanoss.h +++ b/inc/scanoss.h @@ -33,7 +33,7 @@ #define WFP_LN 4 #define WFP_REC_LN 18 -#define SCANOSS_VERSION "5.4.25" +#define SCANOSS_VERSION "5.4.26" /* Log files */ #define SCAN_LOG "/tmp/scanoss_scan.log"