Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] expect: Fix segfaults if Tcl is built with stubs and Expect is used directly from C program
@ 2017-09-28  9:53 Li Zhou
  2017-09-28 10:00 ` ✗ patchtest: failure for " Patchwork
  0 siblings, 1 reply; 2+ messages in thread
From: Li Zhou @ 2017-09-28  9:53 UTC (permalink / raw)
  To: openembedded-core

Fix segfaults if Tcl is built with stubs and Expect clib function is used
directly from C program.

Signed-off-by: Li Zhou <li.zhou@windriver.com>
---
 ...segfaults-if-Tcl-is-built-with-stubs-and-.patch | 90 ++++++++++++++++++++++
 meta/recipes-devtools/expect/expect_5.45.bb        |  1 +
 2 files changed, 91 insertions(+)
 create mode 100644 meta/recipes-devtools/expect/expect/0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch

diff --git a/meta/recipes-devtools/expect/expect/0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch b/meta/recipes-devtools/expect/expect/0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch
new file mode 100644
index 0000000..d1619ba
--- /dev/null
+++ b/meta/recipes-devtools/expect/expect/0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch
@@ -0,0 +1,90 @@
+From f0049b4b2ea55b3b3c53bf6f0275654801c755d2 Mon Sep 17 00:00:00 2001
+From: Li Zhou <li.zhou@windriver.com>
+Date: Thu, 28 Sep 2017 15:54:55 +0800
+Subject: [PATCH] expect: Fix segfaults if Tcl is built with stubs and Expect
+ is used directly from C program
+
+Description: This dirty hack fixes segfaults if Tcl is built with stubs
+ and Expect is used directly from C program.
+Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=588817
+Example:
+ #include <stdio.h>
+ #include <tcl8.5/expect.h>
+ int main()
+ {
+     FILE *pipe;
+     char *some_command = "uname";
+     char datum;
+     pipe = exp_popen(some_command);
+     if (pipe == NULL) return 1;
+     while ((datum = getc (pipe)) != EOF)
+ 	printf("%c",datum);
+ }
+Example:
+ #include <stdio.h>
+ #include "expect.h"
+ main()
+ {
+     int fd = 0;
+     fd = exp_spawnl("echo", "echo", "Hello User: Whats up?", (char*) 0);
+     switch (exp_expectl(fd, exp_regexp, "ser:", 1, exp_end)) {
+ 	case 1: {
+ 	    printf("GOT ser:\n");
+ 	    break;
+ 	}
+ 	default: {
+ 	    printf("DEFAULT\n");
+ 	    return 1;
+ 	}
+     }
+     printf("Normal Exit\n");
+     return 0;
+ }
+Author: Sergei Golovan <sgolovan@debian.org>
+
+Upstream-Status: Backport
+Backport from http://pkgs.fedoraproject.org/cgit/rpms/expect.git/commit/
+?h=master&id=b6737eed550be93182f2ed194e836a6cbbcf4fa3
+Signed-off-by: Li Zhou <li.zhou@windriver.com>
+---
+ exp_clib.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/exp_clib.c b/exp_clib.c
+index 172c05e..19341d5 100644
+--- a/exp_clib.c
++++ b/exp_clib.c
+@@ -114,7 +114,11 @@ extern unsigned long	strtoul _ANSI_ARGS_((CONST char *string,
+ #include <stdlib.h>		/* for malloc */
+ #endif
+ 
+-#include <tcl.h>
++#define ckalloc(x) Tcl_Alloc(x)
++#define ckfree(x) Tcl_Free(x)
++extern char *Tcl_ErrnoMsg(int err);
++extern char *Tcl_Alloc(unsigned int size);
++extern void Tcl_Free(char *ptr);
+ #include "expect.h"
+ #define TclRegError exp_TclRegError
+ 
+@@ -389,7 +393,7 @@ char *exp;
+ 		FAIL("regexp too big");
+ 
+ 	/* Allocate space. */
+-	r = (regexp *)ckalloc(sizeof(regexp) + (unsigned)rcstate->regsize);
++	r = (regexp *)malloc(sizeof(regexp) + (unsigned)rcstate->regsize);
+ 	if (r == NULL)
+ 		FAIL("out of space");
+ 
+@@ -399,7 +403,7 @@ char *exp;
+ 	rcstate->regcode = r->program;
+ 	regc(MAGIC, rcstate);
+ 	if (reg(0, &flags, rcstate) == NULL) {
+-	  ckfree ((char*) r);
++	  free((char*) r);
+ 	  return(NULL);
+ 	}
+ 
+-- 
+1.9.1
+
diff --git a/meta/recipes-devtools/expect/expect_5.45.bb b/meta/recipes-devtools/expect/expect_5.45.bb
index e2d24e8..c9f5aba 100644
--- a/meta/recipes-devtools/expect/expect_5.45.bb
+++ b/meta/recipes-devtools/expect/expect_5.45.bb
@@ -26,6 +26,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/expect/Expect/${PV}/${BPN}${PV}.tar.gz \
            file://01-example-shebang.patch \
            file://0001-expect-install-scripts-without-using-the-fixline1-tc.patch \
            file://0001-Resolve-string-formatting-issues.patch \
+           file://0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch \
           "
 SRC_URI[md5sum] = "44e1a4f4c877e9ddc5a542dfa7ecc92b"
 SRC_URI[sha256sum] = "b28dca90428a3b30e650525cdc16255d76bb6ccd65d448be53e620d95d5cc040"
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* ✗ patchtest: failure for expect: Fix segfaults if Tcl is built with stubs and Expect is used directly from C program
  2017-09-28  9:53 [PATCH] expect: Fix segfaults if Tcl is built with stubs and Expect is used directly from C program Li Zhou
@ 2017-09-28 10:00 ` Patchwork
  0 siblings, 0 replies; 2+ messages in thread
From: Patchwork @ 2017-09-28 10:00 UTC (permalink / raw)
  To: Li Zhou; +Cc: openembedded-core

== Series Details ==

Series: expect: Fix segfaults if Tcl is built with stubs and Expect is used directly from C program
Revision: 1
URL   : https://patchwork.openembedded.org/series/9151/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Patch            expect: Fix segfaults if Tcl is built with stubs and Expect is used directly from C program
 Issue             Commit shortlog is too long [test_shortlog_length] 
  Suggested fix    Edit shortlog so that it is 90 characters or less (currently 91 characters)



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-28 10:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-28  9:53 [PATCH] expect: Fix segfaults if Tcl is built with stubs and Expect is used directly from C program Li Zhou
2017-09-28 10:00 ` ✗ patchtest: failure for " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox