Flag real errors from macro define and undefine errors

This WILL cause behavior changes in cases where there have been
illegal macro names etc which have previously been more or less
ignored with an logged error, but now they will actually abort.
This commit is contained in:
Panu Matilainen 2017-01-19 14:15:38 +02:00
parent 8f86427d8a
commit 02dea59e3a
1 changed files with 6 additions and 2 deletions

View File

@ -478,6 +478,7 @@ doDefine(MacroBuf mb, const char * se, size_t slen, int level, int expandbody)
int c; int c;
int oc = ')'; int oc = ')';
const char *sbody; /* as-is body start */ const char *sbody; /* as-is body start */
int rc = 1; /* assume failure */
/* Copy name */ /* Copy name */
COPYNAME(ne, s, c); COPYNAME(ne, s, c);
@ -582,8 +583,11 @@ doDefine(MacroBuf mb, const char * se, size_t slen, int level, int expandbody)
} }
pushMacro(mb->mc, n, o, b, (level - 1), ME_NONE); pushMacro(mb->mc, n, o, b, (level - 1), ME_NONE);
rc = 0;
exit: exit:
if (rc)
mb->error = 1;
_free(buf); _free(buf);
_free(ebody); _free(ebody);
return se; return se;
@ -613,8 +617,8 @@ doUndefine(MacroBuf mb, const char * se, size_t slen)
/* Names must start with alphabetic or _ and be at least 3 chars */ /* Names must start with alphabetic or _ and be at least 3 chars */
if (!((c = *n) && (risalpha(c) || c == '_') && (ne - n) > 2)) { if (!((c = *n) && (risalpha(c) || c == '_') && (ne - n) > 2)) {
rpmlog(RPMLOG_ERR, rpmlog(RPMLOG_ERR, _("Macro %%%s has illegal name (%%undefine)\n"), n);
_("Macro %%%s has illegal name (%%undefine)\n"), n); mb->error = 1;
goto exit; goto exit;
} }