[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [help-gengetopt] Input validation
From: |
Lorenzo Bettini |
Subject: |
Re: [help-gengetopt] Input validation |
Date: |
Thu, 22 Dec 2005 19:20:37 +0100 |
User-agent: |
Debian Thunderbird 1.0.7 (X11/20051017) |
Michael Hagemann wrote:
Hi all,
Ben Asselstine wrote:
The *end parameter to strto[u]l needs to be checked like this:
[...]
I would definitely opt for further checking (for all types actually).
The stricter, the better. The earlier an error is caught, the better.
Maybe I can look into this next week, if nobody else is faster... ;-)
have I been faster? ;-)
I've put up a fix using Ben's template:
http://rap.dsi.unifi.it/~bettini/gengetopt-2.15rc1.tar.gz
now the generated code for a numeric option is as follows:
args_info->int_arg = strtol (optarg, &stop_char, 0);
if (!(stop_char && *stop_char == '\0')) {
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
goto failure;
}
and this should do, shouldn't it?
I look forward to hearing comments.
I'd like to make 2.15 release these days!
thanks everyone
and Happy XMas
Lorenzo
--
+-----------------------------------------------------+
| Lorenzo Bettini ICQ# lbetto, 16080134 |
| PhD in Computer Science |
| Dip. Sistemi e Informatica, Univ. di Firenze |
| Florence - Italy (GNU/Linux User # 158233) |
| Home Page : http://www.lorenzobettini.it |
| http://music.dsi.unifi.it XKlaim language |
| http://www.purplesucker.com Deep Purple Cover Band |
| http://www.gnu.org/software/src-highlite |
| http://www.gnu.org/software/gengetopt |
| http://www.lorenzobettini.it/software/gengen |
| http://www.lorenzobettini.it/software/doublecpp |
+-----------------------------------------------------+