[syslinux] extlinux 6.03 serial console not responding to input

Andrew J. Schorr aschorr at telemetry-investments.com
Tue May 19 21:16:15 PDT 2015


On Tue, May 19, 2015 at 11:42:32PM -0400, Andrew J. Schorr via Syslinux wrote:
> This is completely untested, but something like the attached (where 'atoi'
> is replaced by 'strntoumax(nptr, (char **)NULL, 0, ~(size_t) 0)') might
> do the trick.  The current 'atoi' calls translate to
>    (int) strntoumax(nptr, (char **)NULL, 10, ~(size_t) 0);
> The problem is that they specify base 10.  If the base is left as 0,
> then strntoumax will recognize hex values starting with '0x' and
> octal values starting with '0'.  Is baudrate required to be in base10?
> 
> Note that this patch does not allow the other funky formats in the old
> assembly 'getint' call.  The parseint comment says:
> 
> ;               Syntaxes accepted: [-]dec, [-]0+oct, [-]0x+hex, val+[KMG]
> 
> So if you want to support that last syntax, it wil require further work.

Actually, that last patch was ugly.  It is more elegant to use
the strtoul wrapper instead of calling the underlying strntoumax routine.
So we simply replace atoi(p) with strtoul(p, NULL, 0) in the attached.
We can also pass &p as the 2nd arg to make it slightly more efficient.

By the way, it seems like there's a basic problem here that we can't flag any
errors in the config file.  Is there any way to give an error indication when a
syntax error is encountered?  For example, if it says "serial fubar", the code
treats "fubar" as 0 and does not throw an error.  If there were a way to flag
errors in the config file, I'd tighten up this code considerably...

Regards,
Andy
-------------- next part --------------
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 347f826..dcdf91b 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -1311,7 +1311,7 @@ static void parse_config_file(FILE * f)
 		uint32_t baud;
 
 		p = skipspace(p + 6);
-		port = atoi(p);
+		port = strtoul(p, &p, 0);
 
 		while (isalnum(*p))
 			p++;
@@ -1335,7 +1335,7 @@ static void parse_config_file(FILE * f)
 			flow = 0;
 			if (isalnum(*p)) {
 				/* flow control */
-				flow = atoi(p);
+				flow = strtoul(p, NULL, 0);
 				ignore = ((flow & 0x0F00) >> 4);
 			}
 


More information about the Syslinux mailing list