{
struct winbindd_request request;
struct winbindd_response response;
- char *sid_string = NULL;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
if (!sid || !puid) {
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- wbc_status = wbcSidToString(sid, &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
-
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1);
- wbcFreeMemory(sid_string);
+ wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
/* Make request */
struct winbindd_request request;
struct winbindd_response response;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
- char *sid_string = NULL;
if (!sid || !pgid) {
wbc_status = WBC_ERR_INVALID_PARAM;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- wbc_status = wbcSidToString(sid, &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
-
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1);
- wbcFreeMemory(sid_string);
+ wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
/* Make request */
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct winbindd_request request;
struct winbindd_response response;
- char * sid_string = NULL;
if (!pwd) {
wbc_status = WBC_ERR_INVALID_PARAM;
BAIL_ON_WBC_ERROR(wbc_status);
}
- wbc_status = wbcSidToString(sid, &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
-
/* Initialize request */
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid));
+ wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
wbc_status = wbcRequestResponse(WINBINDD_GETPWSID,
&request,
BAIL_ON_PTR_ERROR(*pwd, wbc_status);
done:
- wbcFreeMemory(sid_string);
return wbc_status;
}
struct winbindd_request request;
struct winbindd_response response;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
- char *sid_string = NULL;
char *domain, *name;
if (!sid) {
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- /* dst is already null terminated from the memset above */
-
- wbc_status = wbcSidToString(sid, &sid_string);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- return wbc_status;
- }
-
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1);
- wbcFreeMemory(sid_string);
+ wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
/* Make request */
char *p;
struct winbindd_request request;
struct winbindd_response response;
- char *sid_string = NULL;
char *domain_name = NULL;
const char **names = NULL;
enum wbcSidType *types = NULL;
BAIL_ON_WBC_ERROR(wbc_status);
}
- wbc_status = wbcSidToString(dom_sid, &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
-
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1);
- wbcFreeMemory(sid_string);
+ wbcSidToStringBuf(dom_sid, request.data.sid, sizeof(request.data.sid));
/* Even if all the Rids were of maximum 32bit values,
we would only have 11 bytes per rid in the final array
const char *s;
struct winbindd_request request;
struct winbindd_response response;
- char *sid_string = NULL;
struct wbcDomainSid *sids = NULL;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
int cmd;
BAIL_ON_WBC_ERROR(wbc_status);
}
- wbc_status = wbcSidToString(user_sid, &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
-
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1);
- wbcFreeMemory(sid_string);
+ wbcSidToStringBuf(user_sid, request.data.sid, sizeof(request.data.sid));
if (domain_groups_only) {
cmd = WINBINDD_GETUSERDOMGROUPS;
const char *s;
struct winbindd_request request;
struct winbindd_response response;
- char *sid_string = NULL;
- ssize_t sid_len;
ssize_t extra_data_len = 0;
char * extra_data = NULL;
ssize_t buflen = 0;
goto done;
}
- wbc_status = wbcSidToString(dom_sid, &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
-
- strncpy(request.data.sid, sid_string, sizeof(request.data.sid)-1);
- wbcFreeMemory(sid_string);
- sid_string = NULL;
+ wbcSidToStringBuf(dom_sid, request.data.sid, sizeof(request.data.sid));
/* Lets assume each sid is around 57 characters
* S-1-5-21-AAAAAAAAAAA-BBBBBBBBBBB-CCCCCCCCCCC-DDDDDDDDDDD\n */
/* Build the sid list */
for (i=0; i<num_sids; i++) {
- wbc_status = wbcSidToString(&sids[i], &sid_string);
- BAIL_ON_WBC_ERROR(wbc_status);
+ char sid_str[WBC_SID_STRING_BUFLEN];
+ size_t sid_len;
- sid_len = strlen(sid_string);
+ sid_len = wbcSidToStringBuf(&sids[i], sid_str, sizeof(sid_str));
if (buflen < extra_data_len + sid_len + 2) {
buflen *= 2;
}
}
- strncpy(&extra_data[extra_data_len], sid_string,
+ strncpy(&extra_data[extra_data_len], sid_str,
buflen - extra_data_len);
extra_data_len += sid_len;
extra_data[extra_data_len++] = '\n';
extra_data[extra_data_len] = '\0';
- wbcFreeMemory(sid_string);
- sid_string = NULL;
}
extra_data_len += 1;
wbc_status = WBC_ERR_SUCCESS;
done:
- wbcFreeMemory(sid_string);
free(extra_data);
winbindd_free_response(&response);
wbcFreeMemory(rids);