diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:50:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-28 12:50:39 +0100 |
| commit | e7dd07c8025b169b7b43b955066a7200d9cdf244 (patch) | |
| tree | 6e8c927cfc67f3708b91ac79df07707af26e4929 /gl/vasprintf.c | |
| parent | 828a9720b10814c5836d03aa35af05d196c4104b (diff) | |
| parent | b0afb8fe0ff1d87165af9df61501197a06240dda (diff) | |
| download | monitoring-plugins-e7dd07c8025b169b7b43b955066a7200d9cdf244.tar.gz | |
Merge pull request #2213 from RincewindsHat/update/gnulib
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/vasprintf.c')
| -rw-r--r-- | gl/vasprintf.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gl/vasprintf.c b/gl/vasprintf.c index e52aaca5..30aa4469 100644 --- a/gl/vasprintf.c +++ b/gl/vasprintf.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Formatted output to strings. | 1 | /* Formatted output to strings. |
| 2 | Copyright (C) 1999, 2002, 2006-2024 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2002, 2006-2025 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is free software: you can redistribute it and/or modify | 4 | This file is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU Lesser General Public License as | 5 | it under the terms of the GNU Lesser General Public License as |
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #include <errno.h> | 26 | #include <errno.h> |
| 27 | #include <limits.h> | 27 | #include <limits.h> |
| 28 | #include <stdint.h> | ||
| 28 | #include <stdlib.h> | 29 | #include <stdlib.h> |
| 29 | 30 | ||
| 30 | #include "vasnprintf.h" | 31 | #include "vasnprintf.h" |
| @@ -37,12 +38,21 @@ vasprintf (char **resultp, const char *format, va_list args) | |||
| 37 | if (result == NULL) | 38 | if (result == NULL) |
| 38 | return -1; | 39 | return -1; |
| 39 | 40 | ||
| 41 | #if PTRDIFF_MAX > INT_MAX | ||
| 40 | if (length > INT_MAX) | 42 | if (length > INT_MAX) |
| 41 | { | 43 | { |
| 42 | free (result); | 44 | free (result); |
| 43 | errno = EOVERFLOW; | 45 | errno = (length > PTRDIFF_MAX ? ENOMEM : EOVERFLOW); |
| 44 | return -1; | 46 | return -1; |
| 45 | } | 47 | } |
| 48 | #else | ||
| 49 | if (length > PTRDIFF_MAX) | ||
| 50 | { | ||
| 51 | free (result); | ||
| 52 | errno = ENOMEM; | ||
| 53 | return -1; | ||
| 54 | } | ||
| 55 | #endif | ||
| 46 | 56 | ||
| 47 | *resultp = result; | 57 | *resultp = result; |
| 48 | /* Return the number of resulting bytes, excluding the trailing NUL. */ | 58 | /* Return the number of resulting bytes, excluding the trailing NUL. */ |
