You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Enable format-overflow=2 compiler warning.
Warn about calls to formatted input/output functions such as sprintf and vsprintf that might overflow the destination buffer. This warning found a few short float buffers. In practice these are unlikely to ever be a problem based on our float usage but best to be safe. Note that this warning only requires the buffer size to be 317 but it must be 318 to prevent warnings from -Wformat-truncation=2. We are not ready to enable that warning yet but seems better to get the buffer correct now.
This commit is contained in:
		| @@ -58,6 +58,9 @@ warning_enable = [ | ||||
|     # Enable -Wformat plus -Wnonnull, -Wformat-nonliteral, -Wformat-security, and -Wformat-y2k | ||||
|     '-Wformat=2', | ||||
|  | ||||
|     # Warn about calls to formatted input/output functions such as sprintf and vsprintf that might overflow the destination buffer | ||||
|     '-Wformat-overflow=2', | ||||
|  | ||||
|     # Warn if the format string requires an unsigned argument and the argument is signed and vice versa | ||||
|     '-Wformat-signedness', | ||||
|  | ||||
|   | ||||
| @@ -19,6 +19,7 @@ Required buffer sizes | ||||
| ***********************************************************************************************************************************/ | ||||
| #define CVT_BOOL_BUFFER_SIZE                                        6 | ||||
| #define CVT_BASE10_BUFFER_SIZE                                      64 | ||||
| #define CVT_DOUBLE_BUFFER_SIZE                                      318 | ||||
| #define CVT_VARINT128_BUFFER_SIZE                                   10 | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
|   | ||||
| @@ -168,7 +168,7 @@ strNewDbl(const double value) | ||||
|         FUNCTION_TEST_PARAM(DOUBLE, value); | ||||
|     FUNCTION_TEST_END(); | ||||
|  | ||||
|     char working[CVT_BASE10_BUFFER_SIZE]; | ||||
|     char working[CVT_DOUBLE_BUFFER_SIZE]; | ||||
|  | ||||
|     cvtDoubleToZ(value, working, sizeof(working)); | ||||
|  | ||||
|   | ||||
| @@ -526,8 +526,8 @@ hrnTestResultDouble(double actual, double expected) | ||||
|  | ||||
|     if (actual != expected) | ||||
|     { | ||||
|         char actualZ[256]; | ||||
|         char expectedZ[256]; | ||||
|         char actualZ[318]; | ||||
|         char expectedZ[318]; | ||||
|  | ||||
|         snprintf(actualZ, sizeof(actualZ), "%f", actual); | ||||
|         snprintf(expectedZ, sizeof(expectedZ), "%f", expected); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user