Package: minicom
Version: 2.1-10
Severity: normal
Tags: patch

try adding a comment line to /etc/minicom/minirc.fubar that is longer
than 80 chars.  It screws up linecounting for future error reports
about the config file, and (worse!) it tries to evaluate the tail of
that line after char 80 as though the tail were a new line.

for example, the following line as line 5 of the config:

# this is a very long config file comment, but many people do such things, so 
we should handle it gracefully.

generates the weird error:

** Line 6 of the global config file not understood

because minicom is trying to interpret 
"e should handle it gracefully." as a configuration directive.


The attached patch increases the buffer size to 256, and gracefully
rejects any lines larger than the buffer size with a single warning,
while not trying to interpret the tails of those lines.

you should be able to drop it into debian/patches and have it take
effect.

i'm not skilled enough in C-based parsers to rewrite the code to
gracefully handle arbitrarily-sized lines and actually interpret them
without doing a complete overhaul of src/rwconf.c, which i didn't want
to get into.

Thanks for maintaining this package.  i use it often.

        --dkg


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (700, 'testing'), (700, 'stable'), (600, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages minicom depends on:
ii  libc6                         2.3.5-8    GNU C Library: Shared libraries an
ii  libncurses5                   5.5-1      Shared libraries for terminal hand

Versions of packages minicom recommends:
ii  lrzsz                         0.12.21-4  Tools for zmodem/xmodem/ymodem fil

-- no debconf information
--- minicom-2.1.orig/src/rwconf.c	2005-11-18 20:18:31.000000000 -0500
+++ minicom-2.1/src/rwconf.c	2005-11-26 14:49:52.000000000 -0500
@@ -246,16 +246,33 @@
 int init;
 {
   struct pars *p;
-  char line[80];
+  char line[256];
   char *s;
   int public;
   int dosleep = 0;
   int lineno = 0;
   int matched;
+  int badline = 0;
 
   if (init) strcpy(P_SCRIPTPROG, "runscript");
 
-  while(fgets(line, 80, fp) != (char *)0) {
+  while(fgets(line, sizeof(line), fp) != (char *)0) {
+
+    if ((line[strlen(line) - 1] != '\n') && !feof(fp)) {
+      if (! badline) { /*this is the first buffer overrun on this line, so warn about it:*/
+	fprintf(stderr,
+		_("** line %d of the %s config is longer than %d characters: minicom can't handle this.\n"),
+		lineno, init ? _("global") : _("personal"), sizeof(line));
+      }
+      dosleep = 1;
+      /* remember that this is a bad line, and loop */
+      badline = 1;
+      continue;
+    } else if (badline) {
+      /* we just got the tail end of a bad line, so clear the flag and loop: */
+      badline = 0;
+      continue;
+    }
 
 	lineno++;
 

Reply via email to