diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-03-03 00:58:06 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-03-03 00:58:06 +0100 |
commit | 7b24514f549f65ecc30ad06312a775b65ff99653 (patch) | |
tree | 139f965e03fa2c975c2dc93dcb72a54c9a7ab655 /kern/ipc_mig.c | |
parent | b9a59e483225093dec4e28ee5841b5b7f5e73562 (diff) | |
parent | 2d91aeafcf87e32fd3b5d447e20f421ee5d9f91f (diff) |
Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
Diffstat (limited to 'kern/ipc_mig.c')
-rw-r--r-- | kern/ipc_mig.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index bbc38cf..f2c3f45 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -272,10 +272,10 @@ mig_put_reply_port( /* * mig_strncpy.c - by Joshua Block * - * mig_strncp -- Bounded string copy. Does what the library routine strncpy - * OUGHT to do: Copies the (null terminated) string in src into dest, a - * buffer of length len. Assures that the copy is still null terminated - * and doesn't overflow the buffer, truncating the copy if necessary. + * mig_strncpy -- Bounded string copy. Does what the library routine + * strncpy does: Copies the (null terminated) string in src into dest, + * a buffer of length len. Returns the length of the destination + * string excluding the terminating null. * * Parameters: * @@ -285,22 +285,26 @@ mig_put_reply_port( * * len - Length of destination buffer. */ -void mig_strncpy(dest, src, len) -char *dest; -const char *src; -int len; +vm_size_t +mig_strncpy(dest, src, len) + char *dest; + const char *src; + int len; { - int i; + char *dest_ = dest; + int i; - if (len <= 0) - return; + if (len <= 0) + return 0; - for (i=1; i<len; i++) - if (! (*dest++ = *src++)) - return; + for (i = 0; i < len; i++) { + if (! (*dest = *src)) + break; + dest++; + src++; + } - *dest = '\0'; - return; + return dest - dest_; } #define fast_send_right_lookup(name, port, abort) \ |