Skip to content

Commit 7277357

Browse files
bin/xbps-create: handle invalid alternatives
Co-authored-by: vexalous <vexalous@gmail.com> Reported-by: vexalous <vexalous@gmail.com> Closes: #687
1 parent 2256f8d commit 7277357

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

bin/xbps-create/main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ process_one_alternative(const char *altgrname, const char *val)
249249
if (a == NULL)
250250
die("xbps_array_create");
251251
}
252-
altfiles = strchr(val, ':') + 1;
253-
assert(altfiles);
252+
altfiles = strchr(val, ':');
253+
if (!altfiles)
254+
diex("invalid alternative");
255+
altfiles += 1;
254256

255257
xbps_array_add_cstring(a, altfiles);
256258
xbps_dictionary_set(d, altgrname, a);
@@ -278,7 +280,8 @@ process_dict_of_arrays(const char *key UNUSED, const char *val)
278280

279281
if (strchr(args, ' ') == NULL) {
280282
altgrname = strtok(args, ":");
281-
assert(altgrname);
283+
if (!altgrname)
284+
diex("invalid alternative");
282285
process_one_alternative(altgrname, val);
283286
goto out;
284287
}
@@ -288,9 +291,12 @@ process_dict_of_arrays(const char *key UNUSED, const char *val)
288291
char *b;
289292

290293
b = strdup(p);
291-
assert(b);
294+
if (!b)
295+
die("strdup");
296+
292297
altgrname = strtok(b, ":");
293-
assert(altgrname);
298+
if (!altgrname)
299+
diex("invalid alternative");
294300
process_one_alternative(altgrname, p);
295301
free(b);
296302
}

0 commit comments

Comments
 (0)