diff options
| -rw-r--r-- | meta/recipes-devtools/expect/expect/0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch | 91 | ||||
| -rw-r--r-- | meta/recipes-devtools/expect/expect_5.45.bb | 1 |
2 files changed, 92 insertions, 0 deletions
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 0000000000..b1d322d5c9 --- /dev/null +++ b/meta/recipes-devtools/expect/expect/0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | From f0049b4b2ea55b3b3c53bf6f0275654801c755d2 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Li Zhou <li.zhou@windriver.com> | ||
| 3 | Date: Thu, 28 Sep 2017 15:54:55 +0800 | ||
| 4 | Subject: [PATCH] expect: Fix segfaults if Tcl is built with stubs and Expect | ||
| 5 | is used directly from C program | ||
| 6 | |||
| 7 | Description: This dirty hack fixes segfaults if Tcl is built with stubs | ||
| 8 | and Expect is used directly from C program. | ||
| 9 | Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=588817 | ||
| 10 | Example: | ||
| 11 | #include <stdio.h> | ||
| 12 | #include <tcl8.5/expect.h> | ||
| 13 | int main() | ||
| 14 | { | ||
| 15 | FILE *pipe; | ||
| 16 | char *some_command = "uname"; | ||
| 17 | char datum; | ||
| 18 | pipe = exp_popen(some_command); | ||
| 19 | if (pipe == NULL) return 1; | ||
| 20 | while ((datum = getc (pipe)) != EOF) | ||
| 21 | printf("%c",datum); | ||
| 22 | } | ||
| 23 | Example: | ||
| 24 | #include <stdio.h> | ||
| 25 | #include "expect.h" | ||
| 26 | main() | ||
| 27 | { | ||
| 28 | int fd = 0; | ||
| 29 | fd = exp_spawnl("echo", "echo", "Hello User: Whats up?", (char*) 0); | ||
| 30 | switch (exp_expectl(fd, exp_regexp, "ser:", 1, exp_end)) { | ||
| 31 | case 1: { | ||
| 32 | printf("GOT ser:\n"); | ||
| 33 | break; | ||
| 34 | } | ||
| 35 | default: { | ||
| 36 | printf("DEFAULT\n"); | ||
| 37 | return 1; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | printf("Normal Exit\n"); | ||
| 41 | return 0; | ||
| 42 | } | ||
| 43 | Author: Sergei Golovan <sgolovan@debian.org> | ||
| 44 | |||
| 45 | Upstream-Status: Pending | ||
| 46 | This patch is backported from fedora changes for expect: | ||
| 47 | http://pkgs.fedoraproject.org/cgit/rpms/expect.git/commit/ | ||
| 48 | ?h=master&id=b6737eed550be93182f2ed194e836a6cbbcf4fa3 | ||
| 49 | Signed-off-by: Li Zhou <li.zhou@windriver.com> | ||
| 50 | --- | ||
| 51 | exp_clib.c | 10 +++++++--- | ||
| 52 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
| 53 | |||
| 54 | diff --git a/exp_clib.c b/exp_clib.c | ||
| 55 | index 172c05e..19341d5 100644 | ||
| 56 | --- a/exp_clib.c | ||
| 57 | +++ b/exp_clib.c | ||
| 58 | @@ -114,7 +114,11 @@ extern unsigned long strtoul _ANSI_ARGS_((CONST char *string, | ||
| 59 | #include <stdlib.h> /* for malloc */ | ||
| 60 | #endif | ||
| 61 | |||
| 62 | -#include <tcl.h> | ||
| 63 | +#define ckalloc(x) Tcl_Alloc(x) | ||
| 64 | +#define ckfree(x) Tcl_Free(x) | ||
| 65 | +extern char *Tcl_ErrnoMsg(int err); | ||
| 66 | +extern char *Tcl_Alloc(unsigned int size); | ||
| 67 | +extern void Tcl_Free(char *ptr); | ||
| 68 | #include "expect.h" | ||
| 69 | #define TclRegError exp_TclRegError | ||
| 70 | |||
| 71 | @@ -389,7 +393,7 @@ char *exp; | ||
| 72 | FAIL("regexp too big"); | ||
| 73 | |||
| 74 | /* Allocate space. */ | ||
| 75 | - r = (regexp *)ckalloc(sizeof(regexp) + (unsigned)rcstate->regsize); | ||
| 76 | + r = (regexp *)malloc(sizeof(regexp) + (unsigned)rcstate->regsize); | ||
| 77 | if (r == NULL) | ||
| 78 | FAIL("out of space"); | ||
| 79 | |||
| 80 | @@ -399,7 +403,7 @@ char *exp; | ||
| 81 | rcstate->regcode = r->program; | ||
| 82 | regc(MAGIC, rcstate); | ||
| 83 | if (reg(0, &flags, rcstate) == NULL) { | ||
| 84 | - ckfree ((char*) r); | ||
| 85 | + free((char*) r); | ||
| 86 | return(NULL); | ||
| 87 | } | ||
| 88 | |||
| 89 | -- | ||
| 90 | 1.9.1 | ||
| 91 | |||
diff --git a/meta/recipes-devtools/expect/expect_5.45.bb b/meta/recipes-devtools/expect/expect_5.45.bb index e2d24e8d85..c9f5aba897 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 \ | |||
| 26 | file://01-example-shebang.patch \ | 26 | file://01-example-shebang.patch \ |
| 27 | file://0001-expect-install-scripts-without-using-the-fixline1-tc.patch \ | 27 | file://0001-expect-install-scripts-without-using-the-fixline1-tc.patch \ |
| 28 | file://0001-Resolve-string-formatting-issues.patch \ | 28 | file://0001-Resolve-string-formatting-issues.patch \ |
| 29 | file://0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch \ | ||
| 29 | " | 30 | " |
| 30 | SRC_URI[md5sum] = "44e1a4f4c877e9ddc5a542dfa7ecc92b" | 31 | SRC_URI[md5sum] = "44e1a4f4c877e9ddc5a542dfa7ecc92b" |
| 31 | SRC_URI[sha256sum] = "b28dca90428a3b30e650525cdc16255d76bb6ccd65d448be53e620d95d5cc040" | 32 | SRC_URI[sha256sum] = "b28dca90428a3b30e650525cdc16255d76bb6ccd65d448be53e620d95d5cc040" |
