Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/elfctl/elfctl.c
Show All 35 Lines | |||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <gelf.h> | #include <gelf.h> | ||||
#include <getopt.h> | #include <getopt.h> | ||||
#include <libelf.h> | #include <libelf.h> | ||||
#include <stdbool.h> | #include <stdbool.h> | ||||
#include <stdint.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "_elftc.h" | #include "_elftc.h" | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | for (i = 0; i < len; ++i) { | ||||
feature, featurelist[i].alias, | feature, featurelist[i].alias, | ||||
featurelist[i].alias); | featurelist[i].alias); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (i == len) { | if (i == len) { | ||||
if (isdigit(feature[0])) { | if (isdigit(feature[0])) { | ||||
char *eptr; | char *eptr; | ||||
long val; | unsigned long long val; | ||||
errno = 0; | errno = 0; | ||||
val = strtol(feature, &eptr, 0); | val = strtoll(feature, &eptr, 0); | ||||
if (eptr == feature || *eptr != '\0') | if (eptr == feature || *eptr != '\0') | ||||
errno = EINVAL; | errno = EINVAL; | ||||
else if (val > UINT_MAX) | else if (val > UINT32_MAX) | ||||
errno = ERANGE; | errno = ERANGE; | ||||
if (errno != 0) { | if (errno != 0) { | ||||
warn("%s invalid", feature); | warn("%s invalid", feature); | ||||
return (false); | return (false); | ||||
} | } | ||||
input |= val; | input |= val; | ||||
} else { | } else { | ||||
warnx("%s is not a valid feature", feature); | warnx("%s is not a valid feature", feature); | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |