Merge pull request #250 from ebfe/infinity

bin/xbps-checkvers: avoid infinite loops when checking reverts
This commit is contained in:
Juan RP 2017-10-25 09:19:10 +02:00 committed by GitHub
commit e0f4199fff

View File

@ -529,7 +529,7 @@ check_reverts(const char *repover, const map_item_t reverts)
bool rv = false; bool rv = false;
char *sreverts, *p; char *sreverts, *p;
if (reverts.v.len == 0) if (reverts.v.len == 0 || strlen(repover) < 1)
return rv; return rv;
sreverts = calloc(reverts.v.len+1, sizeof(char)); sreverts = calloc(reverts.v.len+1, sizeof(char));
@ -542,8 +542,10 @@ check_reverts(const char *repover, const map_item_t reverts)
* Check if it's the first character or the previous character is a * Check if it's the first character or the previous character is a
* whitespace. * whitespace.
*/ */
if (p > sreverts && !isalpha(p[-1]) && !isspace(p[-1])) if (p > sreverts && !isalpha(p[-1]) && !isspace(p[-1])) {
p++; // always advance
continue; continue;
}
p += strlen(repover); p += strlen(repover);
/* /*
* Check if it's the last character or if the next character is a * Check if it's the last character or if the next character is a