@@ -126,6 +126,7 @@ int set_small_insert(set_small s, const char *key, void *value)
126126{
127127 union set_small_key_type set_key = { 0 };
128128 set_small_element element = NULL ;
129+ size_t key_size = 0 ;
129130
130131 if (s == NULL || key == NULL || value == NULL )
131132 {
@@ -134,7 +135,8 @@ int set_small_insert(set_small s, const char *key, void *value)
134135 }
135136
136137 /* Copy string into key with last bytes set to 0 */
137- strncpy (set_key .string , key , SET_SMALL_KEY_SIZE );
138+ key_size = strnlen (key , SET_SMALL_KEY_SIZE );
139+ memcpy (set_key .string , key , key_size );
138140
139141 /* Find if the element already exists */
140142 element = set_small_find (s , set_key );
@@ -157,6 +159,7 @@ void *set_small_get(set_small s, const char *key)
157159{
158160 union set_small_key_type set_key = { 0 };
159161 set_small_element element = NULL ;
162+ size_t key_size = 0 ;
160163
161164 if (s == NULL || key == NULL )
162165 {
@@ -165,7 +168,8 @@ void *set_small_get(set_small s, const char *key)
165168 }
166169
167170 /* Copy string into key with last bytes set to 0 */
168- strncpy (set_key .string , key , SET_SMALL_KEY_SIZE );
171+ key_size = strnlen (key , SET_SMALL_KEY_SIZE );
172+ memcpy (set_key .string , key , key_size );
169173
170174 /* Find if the element already exists */
171175 element = set_small_find (s , set_key );
@@ -182,6 +186,7 @@ void *set_small_remove(set_small s, const char *key)
182186{
183187 union set_small_key_type set_key = { 0 };
184188 size_t iterator = 0 ;
189+ size_t key_size = 0 ;
185190
186191 if (s == NULL || key == NULL )
187192 {
@@ -190,7 +195,8 @@ void *set_small_remove(set_small s, const char *key)
190195 }
191196
192197 /* Copy string into key with last bytes set to 0 */
193- strncpy (set_key .string , key , SET_SMALL_KEY_SIZE );
198+ key_size = strnlen (key , SET_SMALL_KEY_SIZE );
199+ memcpy (set_key .string , key , key_size );
194200
195201 /* Find the element and remove it */
196202 for (iterator = 0 ; iterator < s -> size ; ++ iterator )
0 commit comments