mirror of
https://github.com/ericonr/util-linux.git
synced 2024-04-21 09:12:35 -05:00
ipcs: 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
62aa386c4f
commit
b6cd420e03
@ -122,9 +122,14 @@ int main(int argc, char **argv)
|
|||||||
ask_sem = 1;
|
ask_sem = 1;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
|
{
|
||||||
|
char *end = NULL;
|
||||||
|
errno = 0;
|
||||||
permission = strtoul(optarg, NULL, 8);
|
permission = strtoul(optarg, NULL, 8);
|
||||||
|
if (errno || optarg == end || (end && *end))
|
||||||
|
err(EXIT_FAILURE, _("failed to parse mode"));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
case 'V':
|
case 'V':
|
||||||
|
@ -125,12 +125,13 @@ static int remove_id(int type, int iskey, int id)
|
|||||||
static int remove_arg_list(type_id type, int argc, char **argv)
|
static int remove_arg_list(type_id type, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
char *end;
|
char *end = NULL;
|
||||||
int nb_errors = 0;
|
int nb_errors = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
errno = 0;
|
||||||
id = strtoul(argv[0], &end, 10);
|
id = strtoul(argv[0], &end, 10);
|
||||||
if (*end != 0) {
|
if (errno || !end || *end != 0) {
|
||||||
warnx(_("invalid id: %s"), argv[0]);
|
warnx(_("invalid id: %s"), argv[0]);
|
||||||
nb_errors++;
|
nb_errors++;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user