diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:13:40 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:13:40 +0100 |
| commit | b0afb8fe0ff1d87165af9df61501197a06240dda (patch) | |
| tree | 274ac6a96c53ef4c19ab4974ce24a06a233128c5 /gl/vasprintf.c | |
| parent | 68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff) | |
| download | monitoring-plugins-b0afb8fe0ff1d87165af9df61501197a06240dda.tar.gz | |
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. */ |
