mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
nsswitch: winbind_nss_aix: Remove all uses of strcpy.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
a559ac31f7
commit
a8ab1bfb7b
@ -85,13 +85,15 @@ static void logit(const char *format, ...)
|
||||
#define STRCPY_RET(dest, src) \
|
||||
do { \
|
||||
if (strlen(src)+1 > sizeof(dest)) { errno = EINVAL; return -1; } \
|
||||
strcpy(dest, src); \
|
||||
strncpy(dest, src, sizeof(dest)); \
|
||||
dest[sizeof(dest)-1] = '\0'; \
|
||||
} while (0)
|
||||
|
||||
#define STRCPY_RETNULL(dest, src) \
|
||||
do { \
|
||||
if (strlen(src)+1 > sizeof(dest)) { errno = EINVAL; return NULL; } \
|
||||
strcpy(dest, src); \
|
||||
strncpy(dest, src, sizeof(dest)); \
|
||||
dest[sizeof(dest)-1] = '\0'; \
|
||||
} while (0)
|
||||
|
||||
|
||||
@ -578,18 +580,21 @@ static attrval_t pwd_to_groupsids(struct passwd *pwd)
|
||||
{
|
||||
attrval_t r;
|
||||
char *s, *p;
|
||||
size_t mlen;
|
||||
|
||||
if ( (s = wb_aix_getgrset(pwd->pw_name)) == NULL ) {
|
||||
r.attr_flag = EINVAL;
|
||||
return r;
|
||||
}
|
||||
|
||||
if ( (p = malloc(strlen(s)+2)) == NULL ) {
|
||||
mlen = strlen(s)+2;
|
||||
if ( (p = malloc(mlen)) == NULL ) {
|
||||
r.attr_flag = ENOMEM;
|
||||
return r;
|
||||
}
|
||||
|
||||
strcpy(p, s);
|
||||
strncpy(p, s, mlen);
|
||||
p[mlen-1] = '\0';
|
||||
replace_commas(p);
|
||||
free(s);
|
||||
|
||||
@ -855,7 +860,8 @@ static int wb_aix_normalize(char *longname, char *shortname)
|
||||
/* automatically cope with AIX 5.3 with longer usernames
|
||||
when it comes out */
|
||||
if (S_NAMELEN > strlen(longname)) {
|
||||
strcpy(shortname, longname);
|
||||
strncpy(shortname, longname, S_NAMELEN);
|
||||
shortname[S_NAMELEN-1] = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user