Skip to content

Commit

Permalink
Further sanity check for EVR validity on build
Browse files Browse the repository at this point in the history
- Check for multiple ':' and '-'  separators (eg foo >= 1-1-1)
  which is not valid. Based on James Antill's patch on rpm-maint
  (http://lists.rpm.org/pipermail/rpm-maint/2013-November/003640.html)
  but modified to avoid bogus spec line numbers on invalid
  autogenerated dependencies.
  • Loading branch information
pmatilai committed Nov 20, 2013
1 parent 48563ca commit b2cf147
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build/parseReqs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ const char * token;
#define SKIPWHITE(_x) {while(*(_x) && (risspace(*_x) || *(_x) == ',')) (_x)++;}
#define SKIPNONWHITE(_x){while(*(_x) &&!(risspace(*_x) || *(_x) == ',')) (_x)++;}

static int checkSep(const char *s, char c, char **emsg)
{
const char *sep = strchr(s, c);
if (sep && strchr(sep + 1, c)) {
rasprintf(emsg, "Double separator '%c' in: %s", c, s);
return 1;
}
return 0;
}

rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
int index, rpmsenseFlags tagflags)
{
Expand Down Expand Up @@ -154,6 +164,11 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
EVR = xmalloc((ve-v) + 1);
rstrlcpy(EVR, v, (ve-v) + 1);
if (rpmCharCheck(spec, EVR, ve-v, ".-_+:%{}~")) goto exit;

/* While ':' and '-' are valid, only one of each is valid. */
if (checkSep(EVR, '-', &emsg) || checkSep(EVR, ':', &emsg))
goto exit;

re = ve; /* ==> next token after EVR string starts here */
} else
EVR = NULL;
Expand Down

0 comments on commit b2cf147

Please sign in to comment.