Date: Thu, 23 Oct 2008 00:31:15 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r184189 - head/usr.sbin/nscd Message-ID: <200810230031.m9N0VFXJ042765@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Thu Oct 23 00:31:15 2008 New Revision: 184189 URL: http://svn.freebsd.org/changeset/base/184189 Log: Slightly adjust code logic: we allocate a "size"ed length of memory, not size+1. Use strlcpy() to avoid using - 1 as length for strncpy(). Modified: head/usr.sbin/nscd/cachelib.c Modified: head/usr.sbin/nscd/cachelib.c ============================================================================== --- head/usr.sbin/nscd/cachelib.c Thu Oct 23 00:28:21 2008 (r184188) +++ head/usr.sbin/nscd/cachelib.c Thu Oct 23 00:31:15 2008 (r184189) @@ -550,7 +550,7 @@ register_cache_entry(struct cache_ *the_ the_cache->entries = new_entries; } - entry_name_size = strlen(params->entry_name); + entry_name_size = strlen(params->entry_name) + 1; switch (params->entry_type) { case CET_COMMON: @@ -564,9 +564,9 @@ register_cache_entry(struct cache_ *the_ (struct cache_entry_params *)&new_common_entry->common_params; new_common_entry->common_params.entry_name = (char *)calloc(1, - entry_name_size+1); + entry_name_size); assert(new_common_entry->common_params.entry_name != NULL); - strncpy(new_common_entry->common_params.entry_name, + strlcpy(new_common_entry->common_params.entry_name, params->entry_name, entry_name_size); new_common_entry->name = new_common_entry->common_params.entry_name; @@ -618,9 +618,9 @@ register_cache_entry(struct cache_ *the_ (struct cache_entry_params *)&new_mp_entry->mp_params; new_mp_entry->mp_params.entry_name = (char *)calloc(1, - entry_name_size+1); + entry_name_size); assert(new_mp_entry->mp_params.entry_name != NULL); - strncpy(new_mp_entry->mp_params.entry_name, params->entry_name, + strlcpy(new_mp_entry->mp_params.entry_name, params->entry_name, entry_name_size); new_mp_entry->name = new_mp_entry->mp_params.entry_name;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810230031.m9N0VFXJ042765>