mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
ID: 3595188 - minor leaks via options. revert prev, this cleaner naming, changes by Zdenek Styblik
This commit is contained in:
parent
8882955891
commit
75d6c72c5d
@ -370,8 +370,8 @@ ipmi_main(int argc, char ** argv,
|
|||||||
int retry = 0;
|
int retry = 0;
|
||||||
uint32_t timeout = 0;
|
uint32_t timeout = 0;
|
||||||
int authtype = -1;
|
int authtype = -1;
|
||||||
char * tmp = NULL;
|
char * tmp_pass = NULL;
|
||||||
char * tmpe = NULL;
|
char * tmp_env = NULL;
|
||||||
char * hostname = NULL;
|
char * hostname = NULL;
|
||||||
char * username = NULL;
|
char * username = NULL;
|
||||||
char * password = NULL;
|
char * password = NULL;
|
||||||
@ -493,17 +493,16 @@ ipmi_main(int argc, char ** argv,
|
|||||||
"from file %s", optarg);
|
"from file %s", optarg);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
if (tmp)
|
|
||||||
free(tmp);
|
|
||||||
#ifdef HAVE_GETPASSPHRASE
|
#ifdef HAVE_GETPASSPHRASE
|
||||||
tmp = getpassphrase("Password: ");
|
tmp_pass = getpassphrase("Password: ");
|
||||||
#else
|
#else
|
||||||
tmp = getpass("Password: ");
|
tmp_pass = getpass("Password: ");
|
||||||
#endif
|
#endif
|
||||||
if (tmp != NULL) {
|
if (tmp_pass != NULL) {
|
||||||
if (password)
|
if (password)
|
||||||
free(password);
|
free(password);
|
||||||
password = strdup(tmp);
|
password = strdup(tmp_pass);
|
||||||
|
free(tmp_pass);
|
||||||
if (password == NULL) {
|
if (password == NULL) {
|
||||||
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
@ -520,10 +519,10 @@ ipmi_main(int argc, char ** argv,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
if ((tmpe = getenv("IPMI_KGKEY"))) {
|
if ((tmp_env = getenv("IPMI_KGKEY"))) {
|
||||||
if (kgkey)
|
if (kgkey)
|
||||||
free(kgkey);
|
free(kgkey);
|
||||||
kgkey = strdup(tmpe);
|
kgkey = strdup(tmp_env);
|
||||||
if (kgkey == NULL) {
|
if (kgkey == NULL) {
|
||||||
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
@ -542,14 +541,15 @@ ipmi_main(int argc, char ** argv,
|
|||||||
break;
|
break;
|
||||||
case 'Y':
|
case 'Y':
|
||||||
#ifdef HAVE_GETPASSPHRASE
|
#ifdef HAVE_GETPASSPHRASE
|
||||||
tmpe = getpassphrase("Key: ");
|
tmp_pass = getpassphrase("Key: ");
|
||||||
#else
|
#else
|
||||||
tmpe = getpass("Key: ");
|
tmp_pass = getpass("Key: ");
|
||||||
#endif
|
#endif
|
||||||
if (tmpe != NULL) {
|
if (tmp_pass != NULL) {
|
||||||
if (kgkey)
|
if (kgkey)
|
||||||
free(kgkey);
|
free(kgkey);
|
||||||
kgkey = strdup(tmpe);
|
kgkey = strdup(tmp_pass);
|
||||||
|
free(tmp_pass);
|
||||||
if (kgkey == NULL) {
|
if (kgkey == NULL) {
|
||||||
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
@ -620,19 +620,19 @@ ipmi_main(int argc, char ** argv,
|
|||||||
memset(optarg, 'X', i);
|
memset(optarg, 'X', i);
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
if ((tmpe = getenv("IPMITOOL_PASSWORD"))) {
|
if ((tmp_env = getenv("IPMITOOL_PASSWORD"))) {
|
||||||
if (password)
|
if (password)
|
||||||
free(password);
|
free(password);
|
||||||
password = strdup(tmpe);
|
password = strdup(tmp_env);
|
||||||
if (password == NULL) {
|
if (password == NULL) {
|
||||||
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((tmpe = getenv("IPMI_PASSWORD"))) {
|
else if ((tmp_env = getenv("IPMI_PASSWORD"))) {
|
||||||
if (password)
|
if (password)
|
||||||
free(password);
|
free(password);
|
||||||
password = strdup(tmpe);
|
password = strdup(tmp_env);
|
||||||
if (password == NULL) {
|
if (password == NULL) {
|
||||||
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
@ -758,12 +758,13 @@ ipmi_main(int argc, char ** argv,
|
|||||||
if (hostname != NULL && password == NULL &&
|
if (hostname != NULL && password == NULL &&
|
||||||
(authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) {
|
(authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) {
|
||||||
#ifdef HAVE_GETPASSPHRASE
|
#ifdef HAVE_GETPASSPHRASE
|
||||||
tmp = getpassphrase("Password: ");
|
tmp_pass = getpassphrase("Password: ");
|
||||||
#else
|
#else
|
||||||
tmp = getpass("Password: ");
|
tmp_pass = getpass("Password: ");
|
||||||
#endif
|
#endif
|
||||||
if (tmp != NULL) {
|
if (tmp_pass != NULL) {
|
||||||
password = strdup(tmp);
|
password = strdup(tmp_pass);
|
||||||
|
free(tmp_pass);
|
||||||
if (password == NULL) {
|
if (password == NULL) {
|
||||||
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user