diff -up ./lib/ipmi_main.c.minleaks ./lib/ipmi_main.c --- ./lib/ipmi_main.c.minleaks 2012-12-12 11:44:02.177217050 +0100 +++ ./lib/ipmi_main.c 2012-12-12 12:18:11.967076191 +0100 @@ -387,6 +387,7 @@ ipmi_main(int argc, char ** argv, uint32_t timeout = 0; int authtype = -1; char * tmp = NULL; + char * tmpe = NULL; char * hostname = NULL; char * username = NULL; char * password = NULL; @@ -412,6 +413,8 @@ ipmi_main(int argc, char ** argv, { switch (argflag) { case 'I': + if (intfname) + free(intfname); intfname = strdup(optarg); if (intfname == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); @@ -489,6 +492,8 @@ ipmi_main(int argc, char ** argv, csv_output = 1; break; case 'H': + if (hostname) + free(hostname); hostname = strdup(optarg); if (hostname == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); @@ -504,6 +509,8 @@ ipmi_main(int argc, char ** argv, "from file %s", optarg); break; case 'a': + if (tmp) + free(tmp); #ifdef HAVE_GETPASSPHRASE tmp = getpassphrase("Password: "); #else @@ -520,6 +527,8 @@ ipmi_main(int argc, char ** argv, } break; case 'k': + if (kgkey) + free(kgkey); kgkey = strdup(optarg); if (kgkey == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); @@ -527,10 +536,10 @@ ipmi_main(int argc, char ** argv, } break; case 'K': - if ((tmp = getenv("IPMI_KGKEY"))) { + if ((tmpe = getenv("IPMI_KGKEY"))) { if (kgkey) free(kgkey); - kgkey = strdup(tmp); + kgkey = strdup(tmpe); if (kgkey == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); goto out_free; @@ -540,6 +549,8 @@ ipmi_main(int argc, char ** argv, } break; case 'y': + if (kgkey) + free(kgkey); kgkey = ipmi_parse_hex(optarg); if (kgkey == NULL) { goto out_free; @@ -547,14 +558,14 @@ ipmi_main(int argc, char ** argv, break; case 'Y': #ifdef HAVE_GETPASSPHRASE - tmp = getpassphrase("Key: "); + tmpe = getpassphrase("Key: "); #else - tmp = getpass("Key: "); + tmpe = getpass("Key: "); #endif - if (tmp != NULL) { + if (tmpe != NULL) { if (kgkey) free(kgkey); - kgkey = strdup(tmp); + kgkey = strdup(tmpe); if (kgkey == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); goto out_free; @@ -562,6 +573,8 @@ ipmi_main(int argc, char ** argv, } break; case 'U': + if (username) + free(username); if (strlen(optarg) > 16) { lprintf(LOG_ERR, "Username is too long (> 16 bytes)"); goto out_free; @@ -573,6 +586,8 @@ ipmi_main(int argc, char ** argv, } break; case 'S': + if (sdrcache) + free(sdrcache); sdrcache = strdup(optarg); if (sdrcache == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); @@ -581,6 +596,8 @@ ipmi_main(int argc, char ** argv, break; #ifdef ENABLE_ALL_OPTIONS case 'o': + if (oemtype) + free(oemtype); oemtype = strdup(optarg); if (oemtype == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); @@ -595,10 +612,14 @@ ipmi_main(int argc, char ** argv, break; case 'g': /* backwards compatible oem hack */ + if (oemtype) + free(oemtype); oemtype = strdup("intelwv2"); break; case 's': /* backwards compatible oem hack */ + if (oemtype) + free(oemtype); oemtype = strdup("supermicro"); break; case 'P': @@ -615,19 +636,19 @@ ipmi_main(int argc, char ** argv, memset(optarg, 'X', i); break; case 'E': - if ((tmp = getenv("IPMITOOL_PASSWORD"))) { + if ((tmpe = getenv("IPMITOOL_PASSWORD"))) { if (password) free(password); - password = strdup(tmp); + password = strdup(tmpe); if (password == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); goto out_free; } } - else if ((tmp = getenv("IPMI_PASSWORD"))) { + else if ((tmpe = getenv("IPMI_PASSWORD"))) { if (password) free(password); - password = strdup(tmp); + password = strdup(tmpe); if (password == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname); goto out_free; @@ -697,6 +718,8 @@ ipmi_main(int argc, char ** argv, sol_escape_char = optarg[0]; break; case 'O': + if (seloem) + free(seloem); seloem = strdup(optarg); if (seloem == NULL) { lprintf(LOG_ERR, "%s: malloc failure", progname);