1991 svccfg describe -t Segmentation Fault
2742 minor memory allocation issue in svccfg:upgrade_manifestfiles()
Reviewed by: Albert Lee <
[email protected]>
Reviewed by: T Nguyen <
[email protected]>
Approved by: Rich Lowe <
[email protected]>
Approved by: Garrett D'Amore <
[email protected]>
--- a/usr/src/cmd/svc/svccfg/svccfg_libscf.c Tue May 29 10:57:43 2012 -0400
+++ b/usr/src/cmd/svc/svccfg/svccfg_libscf.c Sun May 27 16:49:00 2012 +0200
@@ -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 @@
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 @@
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 @@
* 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 @@
}
}
}
+ free(pname);
free(fval);
cbdata.sc_handle = g_hndl;
--- a/usr/src/lib/libscf/common/scf_tmpl.c Tue May 29 10:57:43 2012 -0400
+++ b/usr/src/lib/libscf/common/scf_tmpl.c Sun May 27 16:49:00 2012 +0200
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
/*
@@ -913,8 +914,10 @@
scf_handle_t *h;
h = scf_instance_handle(inst);
- if (h == NULL)
+ if (h == NULL) {
+ *snap = NULL;
return (-1);
+ }
if ((*snap = scf_snapshot_create(h)) == NULL) {
return (-1);
@@ -2150,7 +2153,8 @@
scf_instance_destroy(t->pt_inst);
t->pt_inst = _get_restarter_inst(h, t->pt_orig_svc,
t->pt_orig_inst, t->pt_snap);
- scf_service_destroy(t->pt_svc);
+ if (t->pt_svc != t->pt_orig_svc)
+ scf_service_destroy(t->pt_svc);
t->pt_svc = NULL;
break;
@@ -2159,7 +2163,8 @@
if (t->pt_inst != t->pt_orig_inst)
scf_instance_destroy(t->pt_inst);
t->pt_inst = _get_global_inst(h);
- scf_service_destroy(t->pt_svc);
+ if (t->pt_svc != t->pt_orig_svc)
+ scf_service_destroy(t->pt_svc);
t->pt_svc = NULL;
break;
@@ -2181,7 +2186,6 @@
goto fail;
}
-
iter = _get_svc_or_inst_iter(h, t);
fail:
return (iter);