[isdn4k-utils PATCH] Fix pppd crash in opt_proto handling
Thomas Jarosch <[email protected]> Thu, 30 Oct 2014 14:22:27 +0100
| Newsgroups | gmane.linux.isdn.i4l.user |
|---|---|
| Message-ID | <1431696.Hx1fBs8PCi@storm> |
The function process_option() in options.c of pppd (2.4.7)
frees existing string pointers. So in our case
it frees a character array that's not allocated dynamically.
-> pppd sometimes crashes, sometimes not.
Bug found with valgrind.
The default "HDLC" value is already set in "proto".
---
pppdcapiplugin/capiplugin.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pppdcapiplugin/capiplugin.c b/pppdcapiplugin/capiplugin.c
index a663a0f..8ee644f 100644
--- a/pppdcapiplugin/capiplugin.c
+++ b/pppdcapiplugin/capiplugin.c
@@ -133,7 +133,7 @@ static STRINGLIST *clis;
#define PROTO_ADSLPPPOA 7
#define PROTO_ADSLPPPOALLC 8
#define PROTO_ANALOGMODEM 9
-static char *opt_proto = "hdlc";
+static char *opt_proto = 0;
static int proto = PROTO_HDLC;
static int opt_avmadsl = 0;
static int opt_vpi = -1; /* T-DSL: 1 */
@@ -501,7 +501,7 @@ static void plugin_check_options(void)
if (!opt_channels) opt_channels = "1";
} else if (strcasecmp(opt_proto, "analogmodem") == 0) {
proto = PROTO_ANALOGMODEM;
- } else {
+ } else if (opt_proto != NULL) {
option_error("capiplugin: unknown protocol \"%s\"", opt_proto);
die(1);
}
--
1.9.3