summaryrefslogtreecommitdiff
path: root/src/base64.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-08-16 15:31:17 +0100
committerPádraig Brady <P@draigBrady.com>2015-09-03 00:34:12 +0100
commita8cc9ce3f290a83dfb656dabfab2a98e765a68a0 (patch)
tree7c1a6fd442383b8aa6e494d18b0354b5719c712f /src/base64.c
parent89c517d9e26ad232d857ba37d897adbef19b30a9 (diff)
downloadcoreutils-a8cc9ce3f290a83dfb656dabfab2a98e765a68a0.tar.xz
base64: use stricter validation on wrap column
* src/base64.c (main): Use the higher level xnumtoumax() rather than xstrtoumax(), which is simpler and improves validation of input. Also pass the _empty_ rather than NULL string as the suffixes parameter so that invalid trailing characters are not allowed. For example -w08 is now flagged as an error, rather than being interpreted as 0. A subsequent commit will further improve verification of numbers with leading zeros by dropping backwards compatibility wrt auto parsing oct and hex numbers. * tests/misc/base64.pl: Add tests for invalid wrap values.
Diffstat (limited to 'src/base64.c')
-rw-r--r--src/base64.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/base64.c b/src/base64.c
index 679044e40..15888fa83 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -29,7 +29,7 @@
#include "fadvise.h"
#include "xstrtol.h"
#include "quote.h"
-#include "quotearg.h"
+#include "xdectoint.h"
#include "xfreopen.h"
#define AUTHORS proper_name ("Simon Josefsson")
@@ -289,9 +289,8 @@ main (int argc, char **argv)
break;
case 'w':
- if (xstrtoumax (optarg, NULL, 0, &wrap_column, NULL) != LONGINT_OK)
- error (EXIT_FAILURE, 0, _("invalid wrap size: %s"),
- quotearg (optarg));
+ wrap_column = xnumtoumax (optarg, 0, 0, UINTMAX_MAX, "",
+ _("invalid wrap size"), 0);
break;
case 'i':