Mercurial > illumos > illumos-gate
changeset 12869:fe654b6a1645
6956565 Need to remove VLAs from ilbd to avoid triggering of CR 6956544
6963518 s/\<ILB_SRC\>/ILB_SRCS in ilbadm/Makefile
author | Sangeeta Misra <Sangeeta.Misra@Sun.COM> |
---|---|
date | Mon, 19 Jul 2010 08:47:53 -0700 |
parents | 2377353d2b97 |
children | 2265ddb6f47d |
files | usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_sg.c usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile |
diffstat | 4 files changed, 157 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c Mon Jul 19 15:59:30 2010 +0200 +++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c Mon Jul 19 08:47:53 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdlib.h> @@ -46,6 +45,10 @@ #define AF_2_IPPROTO(_af) (_af == AF_INET)?IPPROTO_IP:IPPROTO_IPV6 #define IPPROTO_2_AF(_i) (_i == IPPROTO_IP)?AF_INET:AF_INET6 +#define PROTOCOL_LEN 16 /* protocol type */ +#define ADDR_LEN (2 * INET6_ADDRSTRLEN + 1) /* prxy src range */ +#define PORT_LEN 6 /* hcport:1-65535 or "ANY" */ + static ilb_status_t ilbd_disable_one_rule(ilbd_rule_t *, boolean_t); static uint32_t i_flags_d2k(int); @@ -505,12 +508,12 @@ adt_event_data_t *event; au_event_t flag; int scf_val_len = ILBD_MAX_VALUE_LEN; - char aobuf[scf_val_len]; /* algo:topo */ - char pbuf[scf_val_len]; /* protocol */ - char pxbuf[scf_val_len]; /* prxy src range */ - char hcpbuf[scf_val_len]; /* hcport: num or "ANY" */ - char valstr1[scf_val_len]; - char valstr2[scf_val_len]; + char *aobuf = NULL; /* algo:topo */ + char *valstr1 = NULL; + char *valstr2 = NULL; + char pbuf[PROTOCOL_LEN]; /* protocol */ + char pxbuf[ADDR_LEN]; /* prxy src range */ + char hcpbuf[PORT_LEN]; /* hcport */ char addrstr_buf[INET6_ADDRSTRLEN]; char addrstr_buf1[INET6_ADDRSTRLEN]; int audit_error; @@ -564,11 +567,13 @@ event->adt_ilb_disable_rule.rule_name = (char *)audit_rule_name; break; case ILBD_CREATE_RULE: - aobuf[0] = '\0'; - pbuf[0] = '\0'; - valstr1[0] = '\0'; - valstr2[0] = '\0'; - hcpbuf[0] = '\0'; + if (((aobuf = malloc(scf_val_len)) == NULL) || + ((valstr1 = malloc(scf_val_len)) == NULL) || + ((valstr2 = malloc(scf_val_len)) == NULL)) { + logerr("ilbd_audit_rule_event: could not" + " allocate buffer"); + exit(EXIT_FAILURE); + } event->adt_ilb_create_rule.auth_used = NET_ILB_CONFIG_AUTH; @@ -595,15 +600,15 @@ * its TCP by default */ if (rlinfo->rl_proto == IPPROTO_UDP) - (void) snprintf(pbuf, sizeof (pbuf), "UDP"); + (void) snprintf(pbuf, PROTOCOL_LEN, "UDP"); else - (void) snprintf(pbuf, sizeof (pbuf), "TCP"); + (void) snprintf(pbuf, PROTOCOL_LEN, "TCP"); event->adt_ilb_create_rule.protocol = pbuf; /* Fill in algorithm and operation type */ ilbd_algo_to_str(rlinfo->rl_algo, valstr1); ilbd_topo_to_str(rlinfo->rl_topo, valstr2); - (void) snprintf(aobuf, sizeof (aobuf), "%s:%s", + (void) snprintf(aobuf, scf_val_len, "%s:%s", valstr1, valstr2); event->adt_ilb_create_rule.algo_optype = aobuf; @@ -613,13 +618,13 @@ sizeof (addrstr_buf)); if (&rlinfo->rl_nat_src_end == 0) { /* Single address */ - (void) snprintf(pxbuf, sizeof (pxbuf), + (void) snprintf(pxbuf, ADDR_LEN, "%s", addrstr_buf); } else { /* address range */ ilbd_addr2str(&rlinfo->rl_nat_src_end, addrstr_buf1, sizeof (addrstr_buf1)); - (void) snprintf(pxbuf, sizeof (pxbuf), + (void) snprintf(pxbuf, ADDR_LEN, "%s-%s", addrstr_buf, addrstr_buf1); } event->adt_ilb_create_rule.proxy_src = pxbuf; @@ -641,15 +646,14 @@ /* Fill in hcport */ if (rlinfo->rl_hcpflag == ILB_HCI_PROBE_FIX) { /* hcport is specified by user */ - (void) snprintf(hcpbuf, sizeof (hcpbuf), "%d", + (void) snprintf(hcpbuf, PORT_LEN, "%d", rlinfo->rl_hcport); event->adt_ilb_create_rule.hcport = hcpbuf; } else if (rlinfo->rl_hcpflag == ILB_HCI_PROBE_ANY) { /* user has specified "ANY" */ - (void) snprintf(hcpbuf, sizeof (hcpbuf), "ANY"); + (void) snprintf(hcpbuf, PORT_LEN, "ANY"); event->adt_ilb_create_rule.hcport = hcpbuf; } - /* * Fill out the conndrain, nat_timeout and persist_timeout * If the user does not specify them, the default value @@ -683,6 +687,9 @@ } } adt_free_event(event); + free(aobuf); + free(valstr1); + free(valstr2); (void) adt_end_session(ah); }
--- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c Mon Jul 19 15:59:30 2010 +0200 +++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c Mon Jul 19 08:47:53 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdlib.h> @@ -533,7 +532,7 @@ int ret = ILB_STATUS_OK; int i; int scf_val_len = ILBD_MAX_VALUE_LEN; - char valstr[scf_val_len]; + char *valstr = NULL; int valint; uint8_t valbool = 0; ilbd_rule_t *r_ent = NULL; @@ -556,6 +555,8 @@ if (v == NULL) return (ILB_STATUS_INTERNAL); + if ((valstr = malloc(scf_val_len)) == NULL) + return (ILB_STATUS_ENOMEM); switch (type) { case ILBD_RULE_STATUS: valbool = r_ent->irl_flags & ILB_FLAGS_RULE_ENABLED; @@ -564,6 +565,7 @@ ret = ilbd_scf_ip_to_str(r_ent->irl_ipversion, &r_ent->irl_vip, scftype, valstr); if (ret != ILB_STATUS_OK) { + free(valstr); scf_value_destroy(v); return (ret); } @@ -572,11 +574,11 @@ struct protoent *protoent; protoent = getprotobynumber(r_ent->irl_proto); - (void) strlcpy(valstr, protoent->p_name, sizeof (valstr)); + (void) strlcpy(valstr, protoent->p_name, scf_val_len); break; } case ILBD_RULE_PORT: - (void) snprintf(valstr, sizeof (valstr), "%d-%d", + (void) snprintf(valstr, scf_val_len, "%d-%d", r_ent->irl_minport, r_ent->irl_maxport); break; case ILBD_RULE_ALGO: @@ -589,6 +591,7 @@ ret = ilbd_scf_ip_to_str(r_ent->irl_ipversion, &r_ent->irl_nat_src_start, scftype, valstr); if (ret != ILB_STATUS_OK) { + free(valstr); scf_value_destroy(v); return (ret); } @@ -597,6 +600,7 @@ ret = ilbd_scf_ip_to_str(r_ent->irl_ipversion, &r_ent->irl_nat_src_end, scftype, valstr); if (ret != ILB_STATUS_OK) { + free(valstr); scf_value_destroy(v); return (ret); } @@ -605,17 +609,18 @@ ret = ilbd_scf_ip_to_str(r_ent->irl_ipversion, &r_ent->irl_stickymask, scftype, valstr); if (ret != ILB_STATUS_OK) { + free(valstr); scf_value_destroy(v); return (ret); } break; case ILBD_RULE_SGNAME: - (void) strlcpy(valstr, r_ent->irl_sgname, sizeof (valstr)); + (void) strlcpy(valstr, r_ent->irl_sgname, scf_val_len); break; case ILBD_RULE_HCNAME: if (r_ent->irl_hcname[0] != '\0') (void) strlcpy(valstr, r_ent->irl_hcname, - sizeof (valstr)); + scf_val_len); else bzero(valstr, ILBD_MAX_VALUE_LEN); break; @@ -638,13 +643,14 @@ case ILBD_SG_SERVER: if (s_ent->isg_srvcount == 0) { (void) strlcpy(valstr, "EMPTY_SERVERGROUP", - sizeof (valstr)); + scf_val_len); break; } varray = calloc(sizeof (*varray), s_ent->isg_srvcount); if (varray == NULL) { scf_value_destroy(v); + free(valstr); return (ILB_STATUS_ENOMEM); } @@ -652,7 +658,7 @@ if (v == NULL) { for (i--; i >= 0; i--) scf_value_destroy(varray[i]); - free(varray); + free(valstr); return (ILB_STATUS_ENOMEM); } @@ -661,6 +667,7 @@ scf_value_destroy(v); for (i--; i >= 0; i--) scf_value_destroy(varray[i]); + free(valstr); free(varray); return (ret); } @@ -672,9 +679,10 @@ scf_value_destroy(v); *numval = s_ent->isg_srvcount; *val = varray; + free(valstr); return (ret); case ILBD_HC_TEST: - (void) strlcpy(valstr, h_ent->ihc_test, sizeof (valstr)); + (void) strlcpy(valstr, h_ent->ihc_test, scf_val_len); break; case ILBD_HC_TIMEOUT: valint = h_ent->ihc_timeout; @@ -709,6 +717,7 @@ valstr); break; } + free(valstr); varray = calloc(1, sizeof (*varray)); if (varray == NULL) { @@ -718,7 +727,6 @@ varray[0] = v; *val = varray; *numval = 1; - return (ret); } @@ -734,7 +742,7 @@ scf_value_t **val; scf_handle_t *h; int scf_name_len = ILBD_MAX_NAME_LEN; - char scfpgname[scf_name_len]; + char *scfpgbuf; /* property group name or group type */ int i, i_st, i_end; switch (pg_type) { @@ -767,19 +775,21 @@ pg_type, pgname); return (ILB_STATUS_EINVAL); } + if ((scfpgbuf = malloc(scf_name_len)) == NULL) + return (ILB_STATUS_ENOMEM); - ilbd_name_to_scfpgname(pg_type, pgname, scfpgname); + ilbd_name_to_scfpgname(pg_type, pgname, scfpgbuf); - ret = ilbd_scf_retrieve_pg(scfpgname, &pg, B_TRUE); - if (ret != ILB_STATUS_OK) + ret = ilbd_scf_retrieve_pg(scfpgbuf, &pg, B_TRUE); + if (ret != ILB_STATUS_OK) { + free(scfpgbuf); return (ret); + } h = scf_pg_handle(pg); /* fill in props */ for (i = i_st; i < i_end; i++) { int num, j; - int scf_name_len = ILBD_MAX_NAME_LEN; - char propname[scf_name_len]; scf_type_t scftype = prop_tbl[i].scf_proptype; ret = ilbd_data_to_scfval(pg_type, prop_tbl[i].val_type, h, @@ -790,12 +800,12 @@ for (j = 0; j < num; j++) { if (pg_type == ILBD_SCF_SG) { ret = ilbd_get_svr_info(data, j, NULL, - propname); + scfpgbuf); if (ret == ILB_STATUS_ENOENT) { - (void) strlcpy(propname, "EMPTY_SERVER", - ILBD_MAX_NAME_LEN); + (void) strlcpy(scfpgbuf, + "EMPTY_SERVER", scf_name_len); } - ret = ilbd_scf_set_prop(pg, propname, + ret = ilbd_scf_set_prop(pg, scfpgbuf, scftype, val[j]); } else { ret = ilbd_scf_set_prop(pg, @@ -807,6 +817,7 @@ } done: + free(scfpgbuf); ilbd_scf_destroy(h, NULL, NULL, pg); return (ret); } @@ -829,14 +840,16 @@ ilb_status_t ret; scf_propertygroup_t *pg; int scf_name_len = ILBD_MAX_NAME_LEN; - char scfname[scf_name_len]; + char *scfname; + if ((scfname = malloc(scf_name_len)) == NULL) + return (ILB_STATUS_ENOMEM); ilbd_name_to_scfpgname(pg_t, pgname, scfname); ret = ilbd_scf_retrieve_pg(scfname, &pg, B_FALSE); + free(scfname); if (ret != ILB_STATUS_EEXIST) return (ret); - ret = ilbd_scf_delete_pg(pg); ilbd_scf_destroy(scf_pg_handle(pg), NULL, NULL, pg); return (ret); @@ -1023,8 +1036,7 @@ ilb_sg_info_t *s_ent = NULL; ilb_hc_info_t *h_ent = NULL; char ipstr[INET6_ADDRSTRLEN]; - int scf_val_len = ILBD_MAX_VALUE_LEN; - char valstr[scf_val_len]; + char *valstr; int64_t valint; uint8_t valbool; int ipversion; @@ -1042,33 +1054,47 @@ } /* get scf value out */ + if ((valstr = malloc(ILBD_MAX_VALUE_LEN)) == NULL) + return (ILB_STATUS_ENOMEM); switch (scf_type) { case SCF_TYPE_NET_ADDR_V4: if (scf_value_get_as_string_typed(val, - SCF_TYPE_NET_ADDR_V4, ipstr, INET_ADDRSTRLEN) < 0) + SCF_TYPE_NET_ADDR_V4, ipstr, INET_ADDRSTRLEN) < 0) { + free(valstr); return (ILB_STATUS_INTERNAL); + } ipversion = AF_INET; break; case SCF_TYPE_NET_ADDR_V6: if (scf_value_get_as_string_typed(val, - SCF_TYPE_NET_ADDR_V6, ipstr, INET6_ADDRSTRLEN) < 0) + SCF_TYPE_NET_ADDR_V6, ipstr, + INET6_ADDRSTRLEN) < 0) { + free(valstr); return (ILB_STATUS_INTERNAL); + } ipversion = AF_INET6; break; case SCF_TYPE_BOOLEAN: - if (scf_value_get_boolean(val, &valbool) < 0) + if (scf_value_get_boolean(val, &valbool) < 0) { + free(valstr); return (ILB_STATUS_INTERNAL); + } break; case SCF_TYPE_ASTRING: - if (scf_value_get_astring(val, valstr, sizeof (valstr)) - < 0) + if (scf_value_get_astring(val, valstr, + ILBD_MAX_VALUE_LEN) < 0) { + free(valstr); return (ILB_STATUS_INTERNAL); + } break; case SCF_TYPE_INTEGER: - if (scf_value_get_integer(val, &valint) < 0) + if (scf_value_get_integer(val, &valint) < 0) { + free(valstr); return (ILB_STATUS_INTERNAL); + } break; default: + free(valstr); return (ILB_STATUS_INTERNAL); } @@ -1207,6 +1233,7 @@ break; } + free(valstr); return (ret); } @@ -1269,7 +1296,7 @@ scf_iter_t *propiter; scf_property_t *prop; int scf_name_len = ILBD_MAX_NAME_LEN; - char prop_name[scf_name_len]; + char *prop_name = NULL; ilb_status_t ret = ILB_STATUS_OK; int scf_ret = -1; @@ -1285,8 +1312,12 @@ if (scf_iter_pg_properties(propiter, pg) != 0) goto out; + if ((prop_name = malloc(scf_name_len)) == NULL) { + ret = ILB_STATUS_ENOMEM; + goto out; + } while ((scf_ret = scf_iter_next_property(propiter, prop)) == 1) { - if (scf_property_get_name(prop, prop_name, sizeof (prop_name)) + if (scf_property_get_name(prop, prop_name, scf_name_len) < 0) { ret = ilbd_scf_err_to_ilb_err(); goto out; @@ -1296,6 +1327,8 @@ break; } out: + if (prop_name != NULL) + free(prop_name); if (scf_ret == -1) ret = ilbd_scf_err_to_ilb_err(); if (prop != NULL) @@ -1319,6 +1352,8 @@ scf_iter_t *pgiter; scf_propertygroup_t *newpg; int port = *((int *)arg1); + int scf_name_len = ILBD_MAX_NAME_LEN; + char *pg_name = NULL; if (inst == NULL) return (ILB_STATUS_EINVAL); @@ -1338,12 +1373,14 @@ if ((scf_ret = scf_iter_instance_pgs(pgiter, inst)) < 0) goto out; + if ((pg_name = malloc(scf_name_len)) == NULL) { + ret = ILB_STATUS_ENOMEM; + goto out; + } while ((scf_ret = scf_iter_next_pg(pgiter, newpg)) > 0) { ilbd_data_t data; - int scf_name_len = ILBD_MAX_NAME_LEN; - char pg_name[scf_name_len]; - if (scf_pg_get_name(newpg, pg_name, sizeof (pg_name)) < 0) { + if (scf_pg_get_name(newpg, pg_name, scf_name_len) < 0) { ret = ilbd_scf_err_to_ilb_err(); goto out; } @@ -1387,8 +1424,10 @@ strlen(ILBD_PG_NAME_SG)) == 0) { data.sg_data = calloc(1, sizeof (ilb_sg_info_t)); - if (data.sg_data == NULL) - return (ILB_STATUS_ENOMEM); + if (data.sg_data == NULL) { + ret = ILB_STATUS_ENOMEM; + goto out; + } ret = ilbd_scf_pg_walk_props(newpg, ilbd_scf_load_prop, &data); if (ret != ILB_STATUS_OK) { @@ -1433,8 +1472,10 @@ strlen(ILBD_PG_NAME_HC)) == 0) { data.hc_data = calloc(1, sizeof (ilb_hc_info_t)); - if (data.hc_data == NULL) - return (ILB_STATUS_ENOMEM); + if (data.hc_data == NULL) { + ret = ILB_STATUS_ENOMEM; + goto out; + } ret = ilbd_scf_pg_walk_props(newpg, ilbd_scf_load_prop, &data); if (ret != ILB_STATUS_OK) @@ -1454,6 +1495,8 @@ } out: + if (pg_name != NULL) + free(pg_name); if (scf_ret < 0) ret = ilbd_scf_err_to_ilb_err(); scf_pg_destroy(newpg); @@ -1528,14 +1571,17 @@ { int ret; scf_propertygroup_t *scfpg = NULL; - int scf_name_len = ILBD_MAX_NAME_LEN; - char scf_pgname[scf_name_len]; + char *scf_pgname = NULL; scf_type_t scftype; scf_value_t *scfval; scf_handle_t *h; + if ((scf_pgname = malloc(ILBD_MAX_NAME_LEN)) == NULL) + return (ILB_STATUS_ENOMEM); ilbd_name_to_scfpgname(pg_type, pg_name, scf_pgname); ret = ilbd_scf_retrieve_pg(scf_pgname, &scfpg, B_FALSE); + free(scf_pgname); + if (ret != ILB_STATUS_EEXIST) return (ret); @@ -1583,8 +1629,10 @@ scf_value_t *val; ilb_status_t ret; int scf_name_len = ILBD_MAX_NAME_LEN; - char buf[scf_name_len]; - char propname[scf_name_len]; + char *buf = NULL; + + if ((buf = malloc(scf_name_len)) == NULL) + return (ILB_STATUS_ENOMEM); ilbd_name_to_scfpgname(ILBD_SCF_SG, sg->isg_name, buf); ret = ilbd_scf_retrieve_pg(buf, &pg, B_FALSE); @@ -1597,23 +1645,27 @@ logerr("ilbd_scf_add_srv: SCF update failed - entering" " maintenance mode"); (void) smf_maintain_instance(ILB_FMRI, SMF_IMMEDIATE); + free(buf); return (ILB_STATUS_INTERNAL); } if ((h = scf_pg_handle(pg)) == NULL) { ilbd_scf_destroy(NULL, NULL, NULL, pg); + free(buf); return (ilbd_scf_err_to_ilb_err()); } if ((val = scf_value_create(h)) == NULL) { ilbd_scf_destroy(h, NULL, NULL, pg); + free(buf); return (ILB_STATUS_ENOMEM); } ilbd_srv_scf_val(srv, buf); (void) scf_value_set_astring(val, buf); - (void) snprintf(propname, sizeof (propname), "server%d", srv->isv_id); - ret = ilbd_scf_set_prop(pg, propname, SCF_TYPE_ASTRING, val); + (void) snprintf(buf, scf_name_len, "server%d", srv->isv_id); + ret = ilbd_scf_set_prop(pg, buf, SCF_TYPE_ASTRING, val); + free(buf); ilbd_scf_destroy(h, NULL, NULL, pg); scf_value_destroy(val); @@ -1631,10 +1683,12 @@ scf_propertygroup_t *pg; scf_handle_t *h; int scf_name_len = ILBD_MAX_NAME_LEN; - char buf[scf_name_len]; + char *buf; scf_transaction_t *tx = NULL; scf_transaction_entry_t *entry = NULL; + if ((buf = malloc(scf_name_len)) == NULL) + return (ILB_STATUS_ENOMEM); ilbd_name_to_scfpgname(ILBD_SCF_SG, sg->isg_name, buf); ret = ilbd_scf_retrieve_pg(buf, &pg, B_FALSE); /* @@ -1642,14 +1696,17 @@ * cannot happen. THe caller of this function puts service in * maintenance mode. */ - if (ret != ILB_STATUS_EEXIST) + if (ret != ILB_STATUS_EEXIST) { + free(buf); return (ILB_STATUS_INTERNAL); + } ret = ILB_STATUS_OK; if ((h = scf_pg_handle(pg)) == NULL) { logdebug("ilbd_scf_del_srv: scf_pg_handle: %s\n", scf_strerror(scf_error())); ilbd_scf_destroy(NULL, NULL, NULL, pg); + free(buf); return (ilbd_scf_err_to_ilb_err()); } @@ -1661,7 +1718,7 @@ goto out; } - (void) snprintf(buf, sizeof (buf), "server%d", srv->isv_id); + (void) snprintf(buf, scf_name_len, "server%d", srv->isv_id); if (scf_transaction_start(tx, pg) == -1) { logdebug("ilbd_scf_set_prop: start scf transaction failed: " @@ -1682,6 +1739,7 @@ } out: + free(buf); if (entry != NULL) scf_entry_destroy(entry); if (tx != NULL)
--- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_sg.c Mon Jul 19 15:59:30 2010 +0200 +++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_sg.c Mon Jul 19 08:47:53 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdlib.h> @@ -1176,10 +1175,10 @@ char *dot; int scf_name_len = ILBD_MAX_NAME_LEN; int scf_val_len = ILBD_MAX_VALUE_LEN; - char prop_name[scf_name_len]; + char *prop_name = NULL; ilb_ip_addr_t ipaddr; void *addrptr; - char ipstr[INET6_ADDRSTRLEN], valstr[scf_val_len]; + char ipstr[INET6_ADDRSTRLEN], *valstr = NULL; int ipver, vallen; char sgname[ILB_NAMESZ]; uint32_t nflags; @@ -1399,11 +1398,18 @@ goto rollback_rules; } - (void) snprintf(valstr, sizeof (valstr), "%s;%d;%d-%d;%d", + if ((prop_name = malloc(scf_name_len)) == NULL) + return (ILB_STATUS_ENOMEM); + if ((valstr = malloc(scf_val_len)) == NULL) { + free(prop_name); + return (ILB_STATUS_ENOMEM); + } + + (void) snprintf(valstr, scf_val_len, "%s;%d;%d-%d;%d", ipstr, ipver, ntohs(tmp_srv->isv_minport), ntohs(tmp_srv->isv_maxport), nflags); - (void) snprintf(prop_name, sizeof (prop_name), "server%d", + (void) snprintf(prop_name, scf_name_len, "server%d", tmp_srv->isv_id); switch (cmd) { @@ -1420,6 +1426,8 @@ SET_SRV_ENABLED(&tmp_srv->isv_srv); break; } + free(prop_name); + free(valstr); if (rc == ILB_STATUS_OK) { switch (cmd) { case stat_disable_server:
--- a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile Mon Jul 19 15:59:30 2010 +0200 +++ b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile Mon Jul 19 08:47:53 2010 -0700 @@ -23,13 +23,10 @@ PROG= ilbadm -ILB_OBJS = ilbadm.o ilbadm_sg.o ilbadm_rules.o ilbadm_hc.o -ILB_OBJS += ilbadm_subr.o ilbadm_import.o ilbadm_nat.o ilbadm_stats.o -OBJS = $(ILB_OBJS) +OBJS = ilbadm.o ilbadm_sg.o ilbadm_rules.o ilbadm_hc.o +OBJS += ilbadm_subr.o ilbadm_import.o ilbadm_nat.o ilbadm_stats.o -ILB_SRCS= $(ILB_OBJS:.o=.c) - -SRCS= $(ILB_SRC) $(LIST_SRCS) +SRCS= $(OBJS:.o=.c) include ../../../Makefile.cmd include ../../../Makefile.ctf @@ -40,7 +37,7 @@ C99MODE = $(C99_ENABLE) -POFILES = $(ILB_OBJS:%.o=%.po) +POFILES = $(OBJS:%.o=%.po) POFILE = $(PROG)_all.po .KEEP_STATE: @@ -61,11 +58,11 @@ clean: $(RM) $(OBJS) $(POFILES) -lint: $(ILB_SRCS) - $(LINT.c) $(ILB_SRCS) $(LDLIBS) +lint: $(SRCS) + $(LINT.c) $(SRCS) $(LDLIBS) -check: $(ILB_SRCS) $(PROG).h - $(CSTYLE) -pP $(ILB_SRCS) $(PROG).h +check: $(SRCS) $(PROG).h + $(CSTYLE) -pP $(SRCS) $(PROG).h $(HDRCHK) $(PROG).h include ../../../Makefile.targ