summaryrefslogtreecommitdiff
path: root/usr/src/cmd/svc
diff options
context:
space:
mode:
authorMilan Jurik <milan.jurik@xylab.cz>2012-05-27 16:49:00 +0200
committerMilan Jurik <milan.jurik@xylab.cz>2012-05-27 16:49:00 +0200
commita58a7fedf7a57cbc5bdaa455cf9134f7a84bbe8f (patch)
treeb1e9241ca537a9900df94e50ba15cdea52208671 /usr/src/cmd/svc
parente18306b13ed357bd545696aa96b53617b64db4a3 (diff)
downloadillumos-joyent-a58a7fedf7a57cbc5bdaa455cf9134f7a84bbe8f.tar.gz
1991 svccfg describe -t Segmentation Fault
2742 minor memory allocation issue in svccfg:upgrade_manifestfiles() Reviewed by: Albert Lee <trisk@nexenta.com> Reviewed by: T Nguyen <truongqnguien@gmail.com> Approved by: Rich Lowe <richlowe@richlowe.net> Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/cmd/svc')
-rw-r--r--usr/src/cmd/svc/svccfg/svccfg_libscf.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr/src/cmd/svc/svccfg/svccfg_libscf.c b/usr/src/cmd/svc/svccfg/svccfg_libscf.c
index e00d10e815..d93a12c904 100644
--- a/usr/src/cmd/svc/svccfg/svccfg_libscf.c
+++ b/usr/src/cmd/svc/svccfg/svccfg_libscf.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
@@ -3900,8 +3901,8 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
pgroup_t *mfst_pgroup;
property_t *mfst_prop;
property_t *old_prop;
- char *pname = malloc(MAXPATHLEN);
- char *fval = NULL;
+ char *pname;
+ char *fval;
char *old_pname;
char *old_fval;
int no_upgrade_pg;
@@ -3971,6 +3972,13 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
SCF_SUCCESS)
return (-1);
+ if ((pname = malloc(MAXPATHLEN)) == NULL)
+ return (ENOMEM);
+ if ((fval = malloc(MAXPATHLEN)) == NULL) {
+ free(pname);
+ return (ENOMEM);
+ }
+
while ((r = scf_iter_next_property(ud_prop_iter, ud_prop)) == 1) {
mfst_seen = 0;
if (scf_property_get_name(ud_prop, pname, MAXPATHLEN) < 0)
@@ -3990,16 +3998,12 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
* property list to get proccessed into the repo.
*/
if (mfst_seen == 0) {
- if (fval == NULL)
- fval = malloc(MAXPATHLEN);
-
/*
* If we cannot get the value then there is no
* reason to attempt to attach the value to
* the property group
*/
- if (fval != NULL &&
- prop_get_val(ud_prop, fname_value) == 0 &&
+ if (prop_get_val(ud_prop, fname_value) == 0 &&
scf_value_get_astring(fname_value, fval,
MAXPATHLEN) != -1) {
old_pname = safe_strdup(pname);
@@ -4016,6 +4020,7 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
}
}
}
+ free(pname);
free(fval);
cbdata.sc_handle = g_hndl;