From: Jindrich Novy Date: Tue, 9 Jun 2009 08:29:01 +0000 (+0200) Subject: Make whitelist of characters allowed in NVR (ticket #59, rhbz#493157) X-Git-Tag: tznext/4.11.0.1.tizen20130304~2950 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7653f770130626dd42e57395d232696d47e66ca3;p=tools%2Flibrpm-tizen.git Make whitelist of characters allowed in NVR (ticket #59, rhbz#493157) --- diff --git a/build/parsePreamble.c b/build/parsePreamble.c index fe1ca65..8d4daea 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -453,6 +453,7 @@ static int handlePreambleTag(rpmSpec spec, Package pkg, rpmTag tag, { char * field = spec->line; char * end, *ch; + char whitelist[] = ".-_+"; int multiToken = 0; rpmsenseFlags tagflags; int rc; @@ -489,7 +490,9 @@ static int handlePreambleTag(rpmSpec spec, Package pkg, rpmTag tag, case RPMTAG_VERSION: case RPMTAG_RELEASE: SINGLE_TOKEN_ONLY; - if ((ch=strchr(field, '/')) != NULL || (ch=strchr(field, '~')) != NULL) { + /* Check whether all characters are sane */ + for (ch=field; *ch; ch++) { + if (risalnum(*ch) || strchr(whitelist, *ch)) continue; rpmlog(RPMLOG_ERR, _("line %d: Illegal char '%c' in: %s\n"), spec->lineNum, *ch, spec->line); return RPMRC_FAIL;