diff options
-rw-r--r-- | src/exit/gnunet-helper-exit-windows.c | 18 | ||||
-rw-r--r-- | src/util/strings.c | 18 | ||||
-rw-r--r-- | src/vpn/gnunet-helper-vpn-windows.c | 18 |
3 files changed, 21 insertions, 33 deletions
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c index 85a06c539..2e4b5f4a2 100644 --- a/src/exit/gnunet-helper-exit-windows.c +++ b/src/exit/gnunet-helper-exit-windows.c | |||
@@ -252,15 +252,12 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | |||
252 | 252 | ||
253 | 253 | ||
254 | /** | 254 | /** |
255 | * Like strlcpy but portable. The given string @a src is copied in full length | 255 | * Like strlcpy but portable. The given string @a src is copied until its null |
256 | * (until its null byte). The destination buffer is guaranteed to be | 256 | * byte or until @a n - 1 bytes have been read. The destination buffer is |
257 | * null-terminated. | 257 | * guaranteed to be null-terminated. |
258 | * | 258 | * |
259 | * to a destination buffer | 259 | * @param dst destination of the copy (must be @a n bytes long) |
260 | * and ensures that the destination string is null-terminated. | 260 | * @param src source of the copy (at most @a n - 1 bytes will be read) |
261 | * | ||
262 | * @param dst destination of the copy | ||
263 | * @param src source of the copy, must be null-terminated | ||
264 | * @param n the length of the string to copy, including its terminating null | 261 | * @param n the length of the string to copy, including its terminating null |
265 | * byte | 262 | * byte |
266 | * @return the length of the string that was copied, excluding the terminating | 263 | * @return the length of the string that was copied, excluding the terminating |
@@ -273,11 +270,10 @@ GNUNET_strlcpy(char *dst, const char *src, size_t n) | |||
273 | size_t slen; | 270 | size_t slen; |
274 | 271 | ||
275 | GNUNET_assert (0 != n); | 272 | GNUNET_assert (0 != n); |
276 | ret = strlen (src); | 273 | slen = strnlen (src, n - 1); |
277 | slen = GNUNET_MIN (ret, n - 1); | ||
278 | memcpy (dst, src, slen); | 274 | memcpy (dst, src, slen); |
279 | dst[slen] = '\0'; | 275 | dst[slen] = '\0'; |
280 | return ret; | 276 | return slen; |
281 | } | 277 | } |
282 | 278 | ||
283 | 279 | ||
diff --git a/src/util/strings.c b/src/util/strings.c index ae0544296..d83c36ef8 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -203,15 +203,12 @@ GNUNET_STRINGS_byte_size_fancy (unsigned long long size) | |||
203 | 203 | ||
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Like strlcpy but portable. The given string @a src is copied in full length | 206 | * Like strlcpy but portable. The given string @a src is copied until its null |
207 | * (until its null byte). The destination buffer is guaranteed to be | 207 | * byte or until @a n - 1 bytes have been read. The destination buffer is |
208 | * null-terminated. | 208 | * guaranteed to be null-terminated. |
209 | * | 209 | * |
210 | * to a destination buffer | 210 | * @param dst destination of the copy (must be @a n bytes long) |
211 | * and ensures that the destination string is null-terminated. | 211 | * @param src source of the copy (at most @a n - 1 bytes will be read) |
212 | * | ||
213 | * @param dst destination of the copy | ||
214 | * @param src source of the copy, must be null-terminated | ||
215 | * @param n the length of the string to copy, including its terminating null | 212 | * @param n the length of the string to copy, including its terminating null |
216 | * byte | 213 | * byte |
217 | * @return the length of the string that was copied, excluding the terminating | 214 | * @return the length of the string that was copied, excluding the terminating |
@@ -224,11 +221,10 @@ GNUNET_strlcpy(char *dst, const char *src, size_t n) | |||
224 | size_t slen; | 221 | size_t slen; |
225 | 222 | ||
226 | GNUNET_assert (0 != n); | 223 | GNUNET_assert (0 != n); |
227 | ret = strlen (src); | 224 | slen = strnlen (src, n - 1); |
228 | slen = GNUNET_MIN (ret, n - 1); | ||
229 | memcpy (dst, src, slen); | 225 | memcpy (dst, src, slen); |
230 | dst[slen] = '\0'; | 226 | dst[slen] = '\0'; |
231 | return ret; | 227 | return slen; |
232 | } | 228 | } |
233 | 229 | ||
234 | 230 | ||
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c index ea4d30347..ab72d71aa 100644 --- a/src/vpn/gnunet-helper-vpn-windows.c +++ b/src/vpn/gnunet-helper-vpn-windows.c | |||
@@ -252,15 +252,12 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | |||
252 | 252 | ||
253 | 253 | ||
254 | /** | 254 | /** |
255 | * Like strlcpy but portable. The given string @a src is copied in full length | 255 | * Like strlcpy but portable. The given string @a src is copied until its null |
256 | * (until its null byte). The destination buffer is guaranteed to be | 256 | * byte or until @a n - 1 bytes have been read. The destination buffer is |
257 | * null-terminated. | 257 | * guaranteed to be null-terminated. |
258 | * | 258 | * |
259 | * to a destination buffer | 259 | * @param dst destination of the copy (must be @a n bytes long) |
260 | * and ensures that the destination string is null-terminated. | 260 | * @param src source of the copy (at most @a n - 1 bytes will be read) |
261 | * | ||
262 | * @param dst destination of the copy | ||
263 | * @param src source of the copy, must be null-terminated | ||
264 | * @param n the length of the string to copy, including its terminating null | 261 | * @param n the length of the string to copy, including its terminating null |
265 | * byte | 262 | * byte |
266 | * @return the length of the string that was copied, excluding the terminating | 263 | * @return the length of the string that was copied, excluding the terminating |
@@ -273,11 +270,10 @@ GNUNET_strlcpy(char *dst, const char *src, size_t n) | |||
273 | size_t slen; | 270 | size_t slen; |
274 | 271 | ||
275 | GNUNET_assert (0 != n); | 272 | GNUNET_assert (0 != n); |
276 | ret = strlen (src); | 273 | slen = strnlen (src, n - 1); |
277 | slen = GNUNET_MIN (ret, n - 1); | ||
278 | memcpy (dst, src, slen); | 274 | memcpy (dst, src, slen); |
279 | dst[slen] = '\0'; | 275 | dst[slen] = '\0'; |
280 | return ret; | 276 | return slen; |
281 | } | 277 | } |
282 | 278 | ||
283 | 279 | ||