Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-updates-src > by-pkgid > c454047046288fa22cc04811dc0287e0 > files > 52

rpm-4.12.0.1-20.3.mga5.src.rpm

diff --git a/build/parseSpec.c b/build/parseSpec.c
index 01620bd..4233b15 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -140,6 +140,24 @@ static OFI_t * popOFI(rpmSpec spec)
     return spec->fileStack;
 }
 
+static int begins_with(const char *s, const char *prefix)
+{
+  return strncmp(s, prefix, strlen(prefix)) == 0;
+}
+
+static int isCommentedDefine(const char *line)
+{
+    const char *p = line;
+
+    SKIPSPACE(p);
+    if (*p++ == '#') {
+        SKIPSPACE(p);
+       if (begins_with(p, "%define") &&
+           isspace(p[strlen("%define")])) return 1;
+    }
+    return 0;
+}
+
 static int restoreFirstChar(rpmSpec spec)
 {
     /* Restore 1st char in (possible) next line */
@@ -171,6 +189,11 @@ static int copyNextLineFromOFI(rpmSpec s
 	spec->lbuf[spec->lbufOff] = '\0';
 	ofi->readPtr = from;
 
+	if (isCommentedDefine(spec->lbuf)) {
+	    rpmlog(RPMLOG_ERR, _("%s:%d: #%%define is forbidden, use #define to comment a %%define\n"), ofi->fileName, ofi->lineNum);
+	    return -1;
+	}
+
 	/* Check if we need another line before expanding the buffer. */
 	for (const char *p = spec->lbuf; *p; p++) {
 	    switch (*p) {