diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-12-21 21:17:55 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-12-21 21:17:55 +0000 |
commit | 1d806c1fb9fdc83d351eb2e988ffc3b0ab85aeb3 (patch) | |
tree | 702c9e0031af579857b13e8b049a9789fb56c41f | |
parent | 3ac58092a2be8970d318ecdf5a06a44271d7f9cd (diff) |
(internal_nis_getprotoent_r): Use strncpy instead of strcpy for
security reasons.
-rw-r--r-- | nis/nss_nis/nis-proto.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c index 92ef1c0010..05437875b2 100644 --- a/nis/nss_nis/nis-proto.c +++ b/nis/nss_nis/nis-proto.c @@ -45,7 +45,7 @@ static struct response *start = NULL; static struct response *next = NULL; static int -saveit (int instatus, char *inkey, int inkeylen, char *inval, +saveit (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata) { if (instatus != YP_TRUE) @@ -68,7 +68,7 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, strncpy (next->val, inval, invallen); next->val[invallen] = '\0'; } - + return 0; } @@ -78,9 +78,9 @@ internal_nis_setprotoent (void) char *domainname; struct ypall_callback ypcb; enum nss_status status; - + yp_get_default_domain (&domainname); - + while (start != NULL) { if (start->val != NULL) @@ -90,12 +90,12 @@ internal_nis_setprotoent (void) free (next); } start = NULL; - + ypcb.foreach = saveit; ypcb.data = NULL; status = yperr2nss (yp_all (domainname, "protocols.bynumber", &ypcb)); next = start; - + return status; } @@ -128,9 +128,9 @@ _nss_nis_endprotoent (void) } start = NULL; next = NULL; - + __libc_lock_unlock (lock); - + return NSS_STATUS_SUCCESS; } @@ -148,12 +148,12 @@ internal_nis_getprotoent_r (struct protoent *proto, do { char *p; - + if (next == NULL) return NSS_STATUS_NOTFOUND; - p = strcpy (buffer, next->val); + p = strncpy (buffer, next->val, buflen); next = next->next; - + while (isspace (*p)) ++p; @@ -162,7 +162,7 @@ internal_nis_getprotoent_r (struct protoent *proto, return NSS_STATUS_TRYAGAIN; } while (!parse_res); - + return NSS_STATUS_SUCCESS; } |