Skip to content

Commit 3d555b8

Browse files
committed
fix bug in the parser of the hwids argument
when several delimiters follows one by one with no data between one of them would be captured as part of the hwid or as a separate hwid for example, ",hwid1,hwid2,," would be parsed as ",hwid1" "hwid2" "," bug occurred due to missing update of hwid_begin
1 parent aad0f0b commit 3d555b8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

generate-cat-file.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ void parse_file_args(char **f_args, int f_count, char *os_attr, struct list_node
11891189
hwid_data->value = hwid_begin; \
11901190
}
11911191

1192-
//note: it does modify hwids content (replace comma with null) and creates references to its particular parts
1192+
//note: it does modify hwids content (replace each comma, that comes 1st after hwid, with null) and creates references to its particular parts
11931193
int parse_hwids_arg(char *hwids, struct list_node **hwid)
11941194
{
11951195
struct list_node *hwid_last = NULL;
@@ -1199,13 +1199,17 @@ int parse_hwids_arg(char *hwids, struct list_node **hwid)
11991199

12001200
while (*hwids)
12011201
{
1202-
if (*hwids == ',' && hwids > hwid_begin)
1202+
if (*hwids == ',')
12031203
{
1204-
FUNC_CREATE_HWID_NODE();
1205-
1206-
//"cut" string to current hwid end
1207-
*hwids = '\0';
1208-
//update current position and move position of current hwid begin to it
1204+
//check if delimiter is NOT immediately after another one (empty entries must be skipped, delimiter is not allowed in the value)
1205+
if (hwids > hwid_begin)
1206+
{
1207+
FUNC_CREATE_HWID_NODE();
1208+
1209+
//"cut" string to current hwid end
1210+
*hwids = '\0';
1211+
}
1212+
//update current position AND move position of current hwid begin to it
12091213
hwid_begin = ++hwids;
12101214
}
12111215
else

0 commit comments

Comments
 (0)