server: public: Add nbdkit_parse_* functions for safely parsing integers.
sscanf is sadly not safe (because it doesn't handle integer overflow
correctly), and strto*l functions are a pain to use correctly.
Therefore add some functions to hide the pain of parsing integers from
the command line.
The simpler uses of sscanf and strto*l are replaced. There are still
a few where we are using advanced features of sscanf.
This changes command line parsing in some corner cases:
* For some parameters you might have written (eg)
‘cache-high-threshold=08’ to mean decimal 8, but now it would be a
parse error. ‘cache-high-threshold=010’ would previously have
parsed as decimal 10, but would now parse as octal 10 (decimal 8).
* Some parameters previously accepted a wider range of values. Now
they will give an error, but the narrower range accepted should
always be more correct.
Thanks: Eric Blake
23 files changed: