changeset 8057:5fea79e09064

6400006 libzonecfg.so.1 zonecfg_strerror() doesn't handle Z_SYSTEM 6579865 zone_rctl_name incorrectly used like a char * in libzonecfg.c 6554794 zoneadm.c: return value of strcmp(3C) compared with NULL pointer
author jv227347 <Jordan.Vaughan@Sun.com>
date Mon, 10 Nov 2008 12:08:25 -0800
parents f52725599bf5
children ead1ee36a8ed
files usr/src/cmd/zoneadm/zoneadm.c usr/src/lib/libzonecfg/common/libzonecfg.c
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/zoneadm/zoneadm.c	Mon Nov 10 11:54:03 2008 -0800
+++ b/usr/src/cmd/zoneadm/zoneadm.c	Mon Nov 10 12:08:25 2008 -0800
@@ -5590,7 +5590,7 @@
 	 * brand type and determine whether it is native or not.
 	 */
 	if ((target_zone != NULL) &&
-	    (strcmp(target_zone, GLOBAL_ZONENAME) != NULL)) {
+	    (strcmp(target_zone, GLOBAL_ZONENAME) != 0)) {
 		if (zone_get_brand(target_zone, target_brand,
 		    sizeof (target_brand)) != Z_OK) {
 			zerror(gettext("missing or invalid brand"));
--- a/usr/src/lib/libzonecfg/common/libzonecfg.c	Mon Nov 10 11:54:03 2008 -0800
+++ b/usr/src/lib/libzonecfg/common/libzonecfg.c	Mon Nov 10 12:08:25 2008 -0800
@@ -24,8 +24,6 @@
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <libsysevent.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -2643,8 +2641,10 @@
 	if ((acltxt == NULL) || (strcmp(acltxt, "") == 0))
 		return (Z_OK);
 
-	if (acl_fromtext(acltxt, &aclp) != 0)
+	if (acl_fromtext(acltxt, &aclp) != 0) {
+		errno = EINVAL;
 		return (Z_SYSTEM);
+	}
 
 	errno = 0;
 	if (acl_set(path, aclp) == -1) {
@@ -2994,8 +2994,7 @@
 	struct zone_rctlvaltab *valptr;
 	int err;
 
-	if (tabptr->zone_rctl_name == NULL ||
-	    strlen(tabptr->zone_rctl_name) == 0)
+	if (strlen(tabptr->zone_rctl_name) == 0)
 		return (Z_INVAL);
 
 	if ((err = operation_prep(handle)) != Z_OK)
@@ -3076,7 +3075,7 @@
 {
 	int err;
 
-	if (tabptr == NULL || tabptr->zone_rctl_name == NULL)
+	if (tabptr == NULL)
 		return (Z_INVAL);
 
 	if ((err = operation_prep(handle)) != Z_OK)
@@ -3120,7 +3119,7 @@
 {
 	int err;
 
-	if (tabptr == NULL || tabptr->zone_rctl_name == NULL)
+	if (tabptr == NULL)
 		return (Z_INVAL);
 
 	if ((err = operation_prep(handle)) != Z_OK)
@@ -3140,8 +3139,7 @@
 {
 	int err;
 
-	if (oldtabptr == NULL || oldtabptr->zone_rctl_name == NULL ||
-	    newtabptr == NULL || newtabptr->zone_rctl_name == NULL)
+	if (oldtabptr == NULL || newtabptr == NULL)
 		return (Z_INVAL);
 
 	if ((err = operation_prep(handle)) != Z_OK)
@@ -3375,6 +3373,8 @@
 		    "Could not create a temporary pool"));
 	case Z_POOL_BIND:
 		return (dgettext(TEXT_DOMAIN, "Could not bind zone to pool"));
+	case Z_SYSTEM:
+		return (strerror(errno));
 	default:
 		return (dgettext(TEXT_DOMAIN, "Unknown error"));
 	}