teknoraver / rpms / rpm

Forked from rpms/rpm 3 months ago
Clone

Blame SOURCES/rpm-4.11.1-empty-lua-script.patch

5860f5
commit 5f3598a700e8e028f9140682262869ca319597ee
5860f5
Author: Panu Matilainen <pmatilai@redhat.com>
5860f5
Date:   Fri Sep 6 16:31:25 2013 +0300
5860f5
5860f5
    Fix segfault executing a -p <lua> scriptlet without a body (RhBug:1004062)
5860f5
    
5860f5
    - There are any number of places where this could be fixed, but
5860f5
      to keep the behavior similar to eg /bin/sh scriptlet without a body,
5860f5
      just turn a non-existent script into an empty string.
5860f5
5860f5
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
5860f5
index 0576318..921cc37 100644
5860f5
--- a/rpmio/rpmlua.c
5860f5
+++ b/rpmio/rpmlua.c
5860f5
@@ -526,6 +526,8 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
5860f5
     int ret = 0;
5860f5
     if (name == NULL)
5860f5
 	name = "<lua>";
5860f5
+    if (script == NULL)
5860f5
+	script = "";
5860f5
     if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
5860f5
 	rpmlog(RPMLOG_ERR, _("invalid syntax in lua script: %s\n"),
5860f5
 		 lua_tostring(L, -1));