From 22a123ac402e7786ab4472c561a9e9a21cd21567 Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Sat, 31 Jan 2009 21:25:45 +0000 Subject: Better integration in unix98 PTY environments. Revised the getopt_long() part. Assured strcpy cases. Thanks to Christoph for contribution. --- ax25ipd/config.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ax25ipd/config.c') diff --git a/ax25ipd/config.c b/ax25ipd/config.c index 4c1db85..e6ae790 100644 --- a/ax25ipd/config.c +++ b/ax25ipd/config.c @@ -205,10 +205,17 @@ char *buf; return 0; } else if (strcmp(p, "device") == 0) { + /* already set? i.e. with commandline option, which overwrites + * the preconfigured setting. useful for systems with unix98 + * style pty's + */ + if (*ttydevice) + return 0; q = strtok(NULL, " \t\n\r"); if (q == NULL) return -1; - strcpy(ttydevice, q); + strncpy(ttydevice, q, sizeof(ttydevice)-1); + ttydevice[sizeof(ttydevice)-1] = 0; return 0; } else if (strcmp(p, "mode") == 0) { @@ -272,10 +279,11 @@ char *buf; q = p + strlen(p) + 1; if (strlen(q) < 2) return -1; /* line ends with a \n */ - if (strlen(q) > sizeof bc_text) + if (strlen(q) > sizeof(bc_text)) return -7; q[strlen(q) - 1] = '\0'; - strcpy(bc_text, q); + strncpy(bc_text, q, sizeof(bc_text)-1); + bc_text[sizeof(bc_text)-1] = 0; return 0; } else if (strcmp(p, "loglevel") == 0) { -- cgit v1.2.3