s3-net: Use wbcSidToStringBuf
authorVolker Lendecke <vl@samba.org>
Fri, 4 Mar 2011 04:53:10 +0000 (05:53 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 5 Mar 2011 13:29:32 +0000 (14:29 +0100)
source3/utils/net_rpc.c

index ae7d5d0c1f0eda88f4378dfefb28c9c9e299d004..0bb4305d59940ca376caaac7ce72fa3080d044e0 100644 (file)
@@ -4617,7 +4617,7 @@ static bool get_user_sids(const char *domain, const char *user, struct security_
        enum wbcSidType type;
        fstring full_name;
        struct wbcDomainSid wsid;
-       char *sid_str = NULL;
+       char sid_str[WBC_SID_STRING_BUFLEN];
        struct dom_sid user_sid;
        uint32_t num_groups;
        gid_t *groups = NULL;
@@ -4636,13 +4636,9 @@ static bool get_user_sids(const char *domain, const char *user, struct security_
                return false;
        }
 
-       wbc_status = wbcSidToString(&wsid, &sid_str);
-       if (!WBC_ERROR_IS_OK(wbc_status)) {
-               return false;
-       }
+       wbcSidToStringBuf(&wsid, sid_str, sizeof(sid_str));
 
        if (type != WBC_SID_NAME_USER) {
-               wbcFreeMemory(sid_str);
                DEBUG(1, ("%s is not a user\n", full_name));
                return false;
        }
@@ -4652,9 +4648,6 @@ static bool get_user_sids(const char *domain, const char *user, struct security_
                return false;
        }
 
-       wbcFreeMemory(sid_str);
-       sid_str = NULL;
-
        init_user_token(token, &user_sid);
 
        /* And now the groups winbind knows about */
@@ -4678,18 +4671,11 @@ static bool get_user_sids(const char *domain, const char *user, struct security_
                        return false;
                }
 
-               wbc_status = wbcSidToString(&wsid, &sid_str);
-               if (!WBC_ERROR_IS_OK(wbc_status)) {
-                       wbcFreeMemory(groups);
-                       return false;
-               }
+               wbcSidToStringBuf(&wsid, sid_str, sizeof(sid_str));
 
                DEBUG(3, (" %s\n", sid_str));
 
                string_to_sid(&sid, sid_str);
-               wbcFreeMemory(sid_str);
-               sid_str = NULL;
-
                add_sid_to_token(token, &sid);
        }
        wbcFreeMemory(groups);