X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fopt%2Fhelpers.c;h=9c181946d6122122c2d89cf3b137129b4bd2f1d9;hb=74257cee33ae3033f961d5f22a0313b8cb1b18d4;hp=0f3671e526d838264d78d8f68b2120acbaa71e44;hpb=f8b1841d26dabd23c053f5fc61dbd1536cdad43c;p=ccan diff --git a/ccan/opt/helpers.c b/ccan/opt/helpers.c index 0f3671e5..9c181946 100644 --- a/ccan/opt/helpers.c +++ b/ccan/opt/helpers.c @@ -1,3 +1,4 @@ +/* Licensed under GPLv3+ - see LICENSE file for details */ #include #include #include @@ -91,10 +92,8 @@ char *opt_set_longval(const char *arg, long *l) *l = strtol(arg, &endp, 0); if (*endp || !arg[0]) return arg_bad("'%s' is not a number", arg); - if (errno == ERANGE) - return arg_bad("'%s' is out of range", arg); if (errno) - return opt_invalid_argument(arg); + return arg_bad("'%s' is out of range", arg); return NULL; } @@ -149,6 +148,8 @@ void opt_show_charp(char buf[OPT_SHOW_LEN], char *const *p) len = OPT_SHOW_LEN - 2; strncpy(buf+1, *p, len); buf[1+len] = '"'; + if (len < OPT_SHOW_LEN - 2) + buf[2+len] = '\0'; } /* Set an integer value, various forms. Sets to 1 on arg == NULL. */