Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/scanoss.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/ignorelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
27 changes: 10 additions & 17 deletions src/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Loading