
jim at meyering
Apr 25, 2012, 8:44 AM
Post #1 of 5
(329 views)
Permalink
|
|
[PATCH] simplify ldap URL construction
|
|
* dirmngr/ldap-url.c (ldap_charray2str): Remove unwarranted uses of strncpy, and simplify. --- Looking at the other strncpy uses, I found these two and saw that they are unnecessary, since we know in each case that the specified length is also the length of the source string. Using stpcpy makes it simpler/clearer. dirmngr/ldap-url.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dirmngr/ldap-url.c b/dirmngr/ldap-url.c index 7b27a30..47441b1 100644 --- a/dirmngr/ldap-url.c +++ b/dirmngr/ldap-url.c @@ -342,16 +342,11 @@ char * ldap_charray2str( char **a, const char *sep ) p = s; for ( v = a; *v != NULL; v++ ) { if ( v != a ) { - strncpy( p, sep, slen ); - p += slen; + p = stpncpy( p, sep, slen ); } - - len = strlen( *v ); - strncpy( p, *v, len ); - p += len; + p = stpcpy( p, *v ); } - *p = '\0'; return s; } -- 1.7.10.335.g879d8 _______________________________________________ Gnupg-devel mailing list Gnupg-devel [at] gnupg http://lists.gnupg.org/mailman/listinfo/gnupg-devel
|