diff options
author | Jindrich Novy <jnovy@redhat.com> | 2009-06-15 08:47:55 +0200 |
---|---|---|
committer | Jindrich Novy <jnovy@redhat.com> | 2009-06-15 08:47:55 +0200 |
commit | ad53979f9ae024083b7f29fe7a914531e487be07 (patch) | |
tree | ee8f9c41653459ed79ce5a2dfe55aaa1cdd68491 /build/parsePreamble.c | |
parent | 8d79668a137e93b5b15613b6f8769d72df831fea (diff) | |
download | librpm-tizen-ad53979f9ae024083b7f29fe7a914531e487be07.tar.gz librpm-tizen-ad53979f9ae024083b7f29fe7a914531e487be07.tar.bz2 librpm-tizen-ad53979f9ae024083b7f29fe7a914531e487be07.zip |
Check for valid chars in Requires/Provides as well
Diffstat (limited to 'build/parsePreamble.c')
-rw-r--r-- | build/parsePreamble.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 6724db8ea..6de05000a 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -446,12 +446,19 @@ if (multiToken) { \ extern int noLang; -/* Check whether all characters are sane */ -static int charCheck(rpmSpec spec, char *field, const char *whitelist) +/** + * Check for inappropriate characters. All alphanums are considered sane. + * @param spec spec + * @param field string to check + * @param fsize size of string to check + * @param whitelist string of permitted characters + * @return RPMRC_OK if OK + */ +rpmRC charCheck(rpmSpec spec, char *field, size_t fsize, const char *whitelist) { - char *ch; + char *ch, *stop = &field[fsize]; - for (ch=field; *ch; ch++) { + for (ch=field; *ch && ch < stop; ch++) { if (risalnum(*ch) || strchr(whitelist, *ch)) continue; if (isprint(*ch)) { rpmlog(RPMLOG_ERR, _("line %d: Illegal char '%c' in: %s\n"), @@ -512,13 +519,13 @@ static int handlePreambleTag(rpmSpec spec, Package pkg, rpmTag tag, switch (tag) { case RPMTAG_NAME: SINGLE_TOKEN_ONLY; - if (charCheck(spec, field, ".-_+") != RPMRC_OK) return RPMRC_FAIL; + if (charCheck(spec, field, strlen(field), ".-_+") != RPMRC_OK) return RPMRC_FAIL; headerPutString(pkg->header, tag, field); break; case RPMTAG_VERSION: case RPMTAG_RELEASE: SINGLE_TOKEN_ONLY; - if (charCheck(spec, field, "._") != RPMRC_OK) return RPMRC_FAIL; + if (charCheck(spec, field, strlen(field), "._+") != RPMRC_OK) return RPMRC_FAIL; headerPutString(pkg->header, tag, field); break; case RPMTAG_URL: |