1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

nsswitch: Update all consumers of strtoul_err(), strtoull_err() to new API

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
This commit is contained in:
Swen Schillig 2019-06-04 09:01:02 +02:00 committed by Ralph Boehme
parent 39a518b671
commit bf020a8c8d
3 changed files with 35 additions and 16 deletions

View File

@ -380,15 +380,27 @@ wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx,
switch (p[0]) {
case 'U':
id->type = WBC_ID_TYPE_UID;
id->id.uid = strtoul_err(p+1, &q, 10, &error);
id->id.uid = smb_strtoul(p+1,
&q,
10,
&error,
SMB_STR_STANDARD);
break;
case 'G':
id->type = WBC_ID_TYPE_GID;
id->id.gid = strtoul_err(p+1, &q, 10, &error);
id->id.gid = smb_strtoul(p+1,
&q,
10,
&error,
SMB_STR_STANDARD);
break;
case 'B':
id->type = WBC_ID_TYPE_BOTH;
id->id.uid = strtoul_err(p+1, &q, 10, &error);
id->id.uid = smb_strtoul(p+1,
&q,
10,
&error,
SMB_STR_STANDARD);
break;
default:
id->type = WBC_ID_TYPE_NOT_SPECIFIED;

View File

@ -122,7 +122,7 @@ wbcErr wbcStringToSid(const char *str,
/* Get the SID revision number */
p = str+2;
x = (uint64_t)strtoul_err(p, &q, 10, &error);
x = (uint64_t)smb_strtoul(p, &q, 10, &error, SMB_STR_STANDARD);
if (x == 0 || x > UINT8_MAX || !q || *q != '-' || error != 0) {
wbc_status = WBC_ERR_INVALID_SID;
BAIL_ON_WBC_ERROR(wbc_status);
@ -135,7 +135,7 @@ wbcErr wbcStringToSid(const char *str,
* be expressed as a hex value, according to MS-DTYP.
*/
p = q+1;
x = strtoull_err(p, &q, 0, &error);
x = smb_strtoull(p, &q, 0, &error, SMB_STR_STANDARD);
if (!q || *q != '-' || (x & AUTHORITY_MASK) || error != 0) {
wbc_status = WBC_ERR_INVALID_SID;
BAIL_ON_WBC_ERROR(wbc_status);
@ -151,7 +151,7 @@ wbcErr wbcStringToSid(const char *str,
p = q +1;
sid->num_auths = 0;
while (sid->num_auths < WBC_MAXSUBAUTHS) {
x = strtoull_err(p, &q, 10, &error);
x = smb_strtoull(p, &q, 10, &error, SMB_STR_ALLOW_NO_CONVERSION);
if (p == q)
break;
if (x > UINT32_MAX || error != 0) {
@ -389,7 +389,7 @@ wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
p = extra_data;
num_domains = strtoul_err(p, &q, 10, &error);
num_domains = smb_strtoul(p, &q, 10, &error, SMB_STR_STANDARD);
if (*q != '\n' || error != 0) {
goto wbc_err_invalid;
}
@ -429,7 +429,7 @@ wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
p = q+1;
}
num_names = strtoul_err(p, &q, 10, &error);
num_names = smb_strtoul(p, &q, 10, &error, SMB_STR_STANDARD);
if (*q != '\n' || error != 0) {
goto wbc_err_invalid;
}
@ -449,7 +449,11 @@ wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
for (i=0; i<num_names; i++) {
names[i].domain_index = strtoul_err(p, &q, 10, &error);
names[i].domain_index = smb_strtoul(p,
&q,
10,
&error,
SMB_STR_STANDARD);
if (names[i].domain_index < 0 || error != 0) {
goto wbc_err_invalid;
}
@ -462,7 +466,7 @@ wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
}
p = q+1;
names[i].type = strtoul_err(p, &q, 10, &error);
names[i].type = smb_strtoul(p, &q, 10, &error, SMB_STR_STANDARD);
if (*q != ' ' || error != 0) {
goto wbc_err_invalid;
}
@ -585,7 +589,11 @@ wbcErr wbcCtxLookupRids(struct wbcContext *ctx, struct wbcDomainSid *dom_sid,
goto done;
}
types[i] = (enum wbcSidType)strtoul_err(p, &q, 10, &error);
types[i] = (enum wbcSidType)smb_strtoul(p,
&q,
10,
&error,
SMB_STR_STANDARD);
if (*q != ' ' || error != 0) {
wbc_status = WBC_ERR_INVALID_RESPONSE;

View File

@ -140,7 +140,7 @@ static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
* Return true if input was valid, false otherwise. */
static bool parse_mapping_arg(char *arg, int *id, char **sid)
{
char *tmp, *endptr;
char *tmp;
int error = 0;
if (!arg || !*arg)
@ -154,9 +154,8 @@ static bool parse_mapping_arg(char *arg, int *id, char **sid)
/* Because atoi() can return 0 on invalid input, which would be a valid
* UID/GID we must use strtoul() and do error checking */
*id = strtoul_err(tmp, &endptr, 10, &error);
if (endptr[0] != '\0' || error != 0)
*id = smb_strtoul(tmp, NULL, 10, &error, SMB_STR_FULL_STR_CONV);
if (error != 0)
return false;
return true;
@ -1421,7 +1420,7 @@ static bool wbinfo_lookuprids(const char *domain, const char *arg)
int error = 0;
uint32_t rid;
rid = strtoul_err(ridstr, NULL, 10, &error);
rid = smb_strtoul(ridstr, NULL, 10, &error, SMB_STR_STANDARD);
if (error != 0) {
d_printf("failed to convert rid\n");
goto done;