Skip to content

Commit b4a145b

Browse files
author
Tomas Winkler
committed
safestring: align str rsize with the mem rsize
The original library departed from standard and set different RSIZE_STR_MAX to 4K and RSIZE_MEM_MAX to 256M The original comment doesn't explain why this decision was done. /* * We depart from the standard and allow memory and string operations to * have different max sizes. See the respective safe_mem_lib.h or * safe_str_lib.h files. */ In this change we allign both RSIZE_STR_MAX and RSIZE_MEM_MAX to same 256M size via standard RSIZE_MAX Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
1 parent b006356 commit b4a145b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

include/safe_lib.h

+4
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ extern "C" {
3232
typedef size_t rsize_t;
3333

3434
/*
35+
* This is the original library decision:
3536
* We depart from the standard and allow memory and string operations to
3637
* have different max sizes. See the respective safe_mem_lib.h or
3738
* safe_str_lib.h files.
3839
*/
3940
/* #define RSIZE_MAX (~(rsize_t)0) - leave here for completeness */
4041

42+
/* Bring back the standard */
43+
#define RSIZE_MAX ( 256UL << 20 ) /* 256MB */
44+
4145
typedef void (*constraint_handler_t) (const char * /* msg */,
4246
void * /* ptr */,
4347
errno_t /* error */);

include/safe_mem_lib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "safe_lib.h"
1212
#include <wchar.h>
1313

14-
#define RSIZE_MAX_MEM ( 256UL << 20 ) /* 256MB */
14+
#define RSIZE_MAX_MEM ( RSIZE_MAX )
1515
#define RSIZE_MAX_MEM16 ( RSIZE_MAX_MEM/2 )
1616
#define RSIZE_MAX_MEM32 ( RSIZE_MAX_MEM/4 )
1717

include/safe_str_lib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define RSIZE_MIN_STR ( 1 )
1717

1818
/* maximum sring length */
19-
#define RSIZE_MAX_STR ( 4UL << 10 ) /* 4KB */
19+
#define RSIZE_MAX_STR ( RSIZE_MAX )
2020

2121

2222
/* The makeup of a password */

0 commit comments

Comments
 (0)