[Pvfs2-cvs] commit by dbonnie in pvfs2/src/common/security: pint-security.c

CVS commit program cvs at parl.clemson.edu
Wed Jun 4 12:07:11 EDT 2008


Update of /anoncvs/pvfs2/src/common/security
In directory parlweb1:/tmp/cvs-serv2276/src/common/security

Modified Files:
      Tag: cu-security-branch
	pint-security.c 
Log Message:
Updated capability init and filled out capability in get-attr.


Index: pint-security.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/security/Attic/pint-security.c,v
diff -p -u -r1.1.2.28 -r1.1.2.29
--- pint-security.c	4 Jun 2008 14:58:17 -0000	1.1.2.28
+++ pint-security.c	4 Jun 2008 16:07:11 -0000	1.1.2.29
@@ -465,22 +465,41 @@ int PINT_verify_capability(PVFS_capabili
 /*  PINT_init_capability
  *
  *  Function to call after creating an initial capability
- *  pointer to initialize needed memory space.
+ *  structure to initialize needed memory space for the signature.
+ *  Sets all fields to 0 or NULL to be safe
  *	
  *  returns -PVFS_ENOMEM on error
+ *  returns -PVFS_EINVAL if passed an invalid structure
  *  returns 0 on success
  */
 int PINT_init_capability(PVFS_capability *cap)
 {
     int ret = 0;
     
+    if (cap)
+    {
+        cap->owner = 0;
+        cap->fsid = 0;
+        cap->sig_size = 0;
+        cap->signature = NULL;
+        cap->timeout = 0;
+        cap->op_mask = 0;
+        cap->num_handles = 0;
+        cap->handle_array = NULL;
+
 #ifndef SECURITY_ENCRYPTION_NONE
-    cap->signature = (unsigned char*)malloc(EVP_PKEY_size(security_privkey));
-    if (cap->signature == NULL)
+        cap->signature = (unsigned char*)malloc(EVP_PKEY_size(security_privkey));
+        if (cap->signature == NULL)
+        {
+            ret = -PVFS_ENOMEM;
+        }
+#endif /* SECURITY_ENCRYPTION_NONE */
+
+    }
+    else
     {
-        ret = -PVFS_ENOMEM;
+        ret = -PVFS_EINVAL;
     }
-#endif /* SECURITY_ENCRYPTION_NONE */
 
     return ret;
 }



More information about the Pvfs2-cvs mailing list