summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2016-03-16 14:04:34 -0700
committerMartin Schwenke <martins@samba.org>2016-03-22 04:38:24 +0100
commita8ab1bfb7beb5483bd3ea2272d05a9fe0d95a1f3 (patch)
treed7677f6742ceb08ca3468797274a5c2e835991ac /nsswitch
parenta559ac31f7d2991fc4b55c505e31736a73c7a0e4 (diff)
downloadsamba-a8ab1bfb7beb5483bd3ea2272d05a9fe0d95a1f3.tar.gz
nsswitch: winbind_nss_aix: Remove all uses of strcpy.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/winbind_nss_aix.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/nsswitch/winbind_nss_aix.c b/nsswitch/winbind_nss_aix.c
index c5c223f4758..dc44db40ef9 100644
--- a/nsswitch/winbind_nss_aix.c
+++ b/nsswitch/winbind_nss_aix.c
@@ -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;
}