[PATCH] Treat single space table entry names specially, i.e., reject them

Erik Auerswald <[email protected]>
Newsgroups gmane.comp.gnu.inetutils.bugs
Message-ID <[email protected]>
Hi,

some tables used with "genget()" use table entries with a single space
character as entry name for special purposes, i.e., as empty lines or
comment lines.  Thus an entry with name " " is not intended as a valid
table entry, but "genget()" does not treat those entries differently from
valid antries.  It should instead reject any attempt to get the entry to
the name " ".

Rejecting to get the table entry for " " would have masked that both
setcmd() and unsetcmd() are not able to handle those table entries.
Thus this rejecting the name " " can be seen to improve robustness.

The attached patch "inetutils-libtelnet-genget-no_space_command.patch"
implements this.

[The genget() function requires "name" to be a valid C string already.]

Thanks,
Erik
-- 
The computing scientist’s main challenge is not to get confused by
the complexities of his own making.
                        -- Edsger W. Dijkstra
inetutils-libtelnet-genget-no_space_command.patch (text/x-diff, 356 B)
diff --git a/libtelnet/genget.c b/libtelnet/genget.c
index 6051f7b4..eae4ecd0 100644
--- a/libtelnet/genget.c
+++ b/libtelnet/genget.c
@@ -87,7 +87,7 @@ genget (char *name, char **table, int stlen)
   register char **c, **found;
   register int n;
 
-  if (name == 0)
+  if (name == 0 || (name[0] == ' ' && name[1] == '\0'))
     return 0;
 
   found = 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.