From 06a81399b8a5a57cddb48b69c87e2d7ff2b2a305 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 13 Dec 2011 10:06:53 +0000 Subject: 2011-12-13 Sebastian Huber * score/include/rtems/score/wkspace.h, score/src/wkstringduplicate.c: Changed parameter of _Workspace_String_duplicate() to avoid strnlen(). --- cpukit/ChangeLog | 5 +++++ cpukit/score/include/rtems/score/wkspace.h | 7 ++----- cpukit/score/src/wkstringduplicate.c | 9 ++++----- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'cpukit') diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 78ab1ca388..81dfea2ea7 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,8 @@ +2011-12-13 Sebastian Huber + + * score/include/rtems/score/wkspace.h, score/src/wkstringduplicate.c: + Changed parameter of _Workspace_String_duplicate() to avoid strnlen(). + 2011-12-13 Ralf Corsépius * configure.ac: Check for getrusage.h decl. diff --git a/cpukit/score/include/rtems/score/wkspace.h b/cpukit/score/include/rtems/score/wkspace.h index 0fc96df6c2..b1d3e88d9f 100644 --- a/cpukit/score/include/rtems/score/wkspace.h +++ b/cpukit/score/include/rtems/score/wkspace.h @@ -102,18 +102,15 @@ void *_Workspace_Allocate_or_fatal_error( /** * @brief Duplicates the @a string with memory from the Workspace. * - * If the @a string length exceeds @a maxlen, then the additional characters - * will be discarded. - * * @param[in] string Pointer to zero terminated string. - * @param[in] maxlen Maximum length of the duplicated string. + * @param[in] len Length of the string (equal to strlen(string)). * * @return NULL Not enough memory. * @return other Duplicated string. */ char *_Workspace_String_duplicate( const char *string, - size_t maxlen + size_t len ); #ifndef __RTEMS_APPLICATION__ diff --git a/cpukit/score/src/wkstringduplicate.c b/cpukit/score/src/wkstringduplicate.c index 55c347a7ca..cef1550a43 100644 --- a/cpukit/score/src/wkstringduplicate.c +++ b/cpukit/score/src/wkstringduplicate.c @@ -24,15 +24,14 @@ char *_Workspace_String_duplicate( const char *string, - size_t maxlen + size_t len ) { - size_t n = strnlen(string, maxlen); - char *dup = _Workspace_Allocate(n + 1); + char *dup = _Workspace_Allocate(len + 1); if (dup != NULL) { - dup [n] = '\0'; - memcpy(dup, string, n); + dup [len] = '\0'; + memcpy(dup, string, len); } return dup; -- cgit v1.2.3