mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-01-21 08:34:29 +08:00
Refix 6e037d6bfbbb93b349c8ca331ebde03a837f76bf
Restore using strncmp() for "options=" and similar substrings. Resolves ipmitool/ipmitool#223 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
parent
aee377bead
commit
50d8c36edf
@ -1070,8 +1070,9 @@ get_bootparam_options(char *optstring,
|
|||||||
|
|
||||||
{NULL} /* End marker */
|
{NULL} /* End marker */
|
||||||
}, *op;
|
}, *op;
|
||||||
|
const char *optkw = "options=";
|
||||||
|
|
||||||
if (strcmp(optstring, "options=")) {
|
if (strncmp(optstring, optkw, strlen(optkw))) {
|
||||||
lprintf(LOG_ERR, "No options= keyword found \"%s\"", optstring);
|
lprintf(LOG_ERR, "No options= keyword found \"%s\"", optstring);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2087,7 +2088,7 @@ ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
/* Exclusive clear-cmos, no other flags */
|
/* Exclusive clear-cmos, no other flags */
|
||||||
optstr = "clear-cmos";
|
optstr = "clear-cmos";
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[2], kw)) {
|
else if (!strncmp(argv[2], kw, strlen(kw))) {
|
||||||
optstr = argv[2] + strlen(kw);
|
optstr = argv[2] + strlen(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -190,6 +190,9 @@ static void rawi2c_usage(void)
|
|||||||
lprintf(LOG_NOTICE, " chan=0 is default, bus= must be specified to use chan=");
|
lprintf(LOG_NOTICE, " chan=0 is default, bus= must be specified to use chan=");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BUS_KW "bus="
|
||||||
|
#define CHAN_KW "chan="
|
||||||
|
|
||||||
int
|
int
|
||||||
ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
|
ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
|
||||||
{
|
{
|
||||||
@ -203,20 +206,20 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
/* handle bus= argument */
|
/* handle bus= argument */
|
||||||
if (argc > 2 && !strcmp(argv[0], "bus=")) {
|
if (argc > 2 && !strncmp(argv[0], BUS_KW, strlen(BUS_KW))) {
|
||||||
i = 1;
|
i = 1;
|
||||||
if (!strcmp(argv[0], "bus=public"))
|
if (!strcmp(argv[0], BUS_KW "public"))
|
||||||
bus = 0;
|
bus = 0;
|
||||||
else if (sscanf(argv[0], "bus=%u", &rbus) == 1)
|
else if (sscanf(argv[0], BUS_KW "%u", &rbus) == 1)
|
||||||
bus = ((rbus & 7) << 1) | 1;
|
bus = ((rbus & 7) << 1) | 1;
|
||||||
else
|
else
|
||||||
bus = 0;
|
bus = 0;
|
||||||
|
|
||||||
/* handle channel= argument
|
/* handle channel= argument
|
||||||
* the bus= argument must be supplied first on command line */
|
* the bus= argument must be supplied first on command line */
|
||||||
if (argc > 3 && !strcmp(argv[1], "chan=")) {
|
if (argc > 3 && !strncmp(argv[1], CHAN_KW, strlen(CHAN_KW))) {
|
||||||
i = 2;
|
i = 2;
|
||||||
if (sscanf(argv[1], "chan=%u", &rbus) == 1)
|
if (sscanf(argv[1], CHAN_KW "%u", &rbus) == 1)
|
||||||
bus |= rbus << 4;
|
bus |= rbus << 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1908,6 +1908,9 @@ int
|
|||||||
ipmi_sol_main(struct ipmi_intf * intf, int argc, char ** argv)
|
ipmi_sol_main(struct ipmi_intf * intf, int argc, char ** argv)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
const char *instance_kw = "instance=";
|
||||||
|
size_t instance_len = strlen(instance_kw);
|
||||||
|
|
||||||
if (!argc || !strcmp(argv[0], "help")) {
|
if (!argc || !strcmp(argv[0], "help")) {
|
||||||
/* Help */
|
/* Help */
|
||||||
print_sol_usage();
|
print_sol_usage();
|
||||||
@ -1991,7 +1994,7 @@ ipmi_sol_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
_use_sol_for_keepalive = 1;
|
_use_sol_for_keepalive = 1;
|
||||||
} else if (!strcmp(argv[i], "nokeepalive")) {
|
} else if (!strcmp(argv[i], "nokeepalive")) {
|
||||||
_disable_keepalive = 1;
|
_disable_keepalive = 1;
|
||||||
} else if (!strcmp(argv[i], "instance=")) {
|
} else if (!strncmp(argv[i], instance_kw, instance_len)) {
|
||||||
if (str2uchar(argv[i] + 9, &instance) != 0) {
|
if (str2uchar(argv[i] + 9, &instance) != 0) {
|
||||||
lprintf(LOG_ERR, "Given instance '%s' is invalid.", argv[i] + 9);
|
lprintf(LOG_ERR, "Given instance '%s' is invalid.", argv[i] + 9);
|
||||||
print_sol_usage();
|
print_sol_usage();
|
||||||
@ -2008,7 +2011,7 @@ ipmi_sol_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
int i;
|
int i;
|
||||||
uint8_t instance = 1;
|
uint8_t instance = 1;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "instance=")) {
|
if (!strncmp(argv[i], instance_kw, instance_len)) {
|
||||||
if (str2uchar(argv[i] + 9, &instance) != 0) {
|
if (str2uchar(argv[i] + 9, &instance) != 0) {
|
||||||
lprintf(LOG_ERR,
|
lprintf(LOG_ERR,
|
||||||
"Given instance '%s' is invalid.",
|
"Given instance '%s' is invalid.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user