readprofile: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
9411b6ccf8
commit
aeba558136
|
@ -125,6 +125,7 @@ usrsbin_exec_PROGRAMS += readprofile
|
||||||
MANPAGES += sys-utils/readprofile.8
|
MANPAGES += sys-utils/readprofile.8
|
||||||
dist_noinst_DATA += sys-utils/readprofile.8.adoc
|
dist_noinst_DATA += sys-utils/readprofile.8.adoc
|
||||||
readprofile_SOURCES = sys-utils/readprofile.c
|
readprofile_SOURCES = sys-utils/readprofile.c
|
||||||
|
readprofile_LDADD = $(LDADD) libcommon.la
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_TUNELP
|
if BUILD_TUNELP
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "c.h"
|
||||||
|
#include "strutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
#include "closestream.h"
|
#include "closestream.h"
|
||||||
|
@ -130,8 +132,8 @@ static void __attribute__((__noreturn__)) usage(void)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *map;
|
FILE *map;
|
||||||
int proFd;
|
int proFd, has_mult = 0, multiplier = 0;
|
||||||
char *mapFile, *proFile, *mult = NULL;
|
char *mapFile, *proFile;
|
||||||
size_t len = 0, indx = 1;
|
size_t len = 0, indx = 1;
|
||||||
unsigned long long add0 = 0;
|
unsigned long long add0 = 0;
|
||||||
unsigned int step;
|
unsigned int step;
|
||||||
|
@ -199,7 +201,8 @@ int main(int argc, char **argv)
|
||||||
optInfo++;
|
optInfo++;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
mult = optarg;
|
multiplier = strtol_or_err(optarg, _("failed to parse multiplier"));
|
||||||
|
has_mult = 1;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
optReset++;
|
optReset++;
|
||||||
|
@ -217,14 +220,13 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optReset || mult) {
|
if (optReset || has_mult) {
|
||||||
int multiplier, fd, to_write;
|
int fd, to_write;
|
||||||
|
|
||||||
/* When writing the multiplier, if the length of the
|
/* When writing the multiplier, if the length of the
|
||||||
* write is not sizeof(int), the multiplier is not
|
* write is not sizeof(int), the multiplier is not
|
||||||
* changed. */
|
* changed. */
|
||||||
if (mult) {
|
if (has_mult) {
|
||||||
multiplier = strtoul(mult, NULL, 10);
|
|
||||||
to_write = sizeof(int);
|
to_write = sizeof(int);
|
||||||
} else {
|
} else {
|
||||||
multiplier = 0;
|
multiplier = 0;
|
||||||
|
|
Loading…
Reference in New Issue