Skip to content

Commit 9256035

Browse files
committed
shm: re-introduce _oidc_strncpy as a __STDC_LIB_EXT1__ macro
possibly using strncpy_s (but not null-checking t->section_key, #1353!) Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 73b2c8a commit 9256035

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/cache/shm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static apr_byte_t oidc_cache_shm_set(request_rec *r, const char *section, const
302302
if (value != NULL) {
303303

304304
/* fill out the entry with the provided data */
305-
_oidc_strcpy(t->section_key, section_key);
305+
_oidc_strncpy(t->section_key, section_key, OIDC_CACHE_SHM_KEY_MAX - 1);
306306
_oidc_strcpy(t->value, value);
307307
t->expires = expiry;
308308
t->access = current_time;

src/const.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@
7070
#define _oidc_memset(b, c, __len) memset_s(b, __len, c, __len)
7171
#define _oidc_memcpy(__dst, __src, __n) memcpy_s(__dst, __src, __n)
7272
#define _oidc_strcpy(__dst, __src) strcpy_s(__dst, __src)
73+
#define _oidc_strncpy(__dst, __src, __n) strncpy_s(__dst, __src, __n)
7374
#else
7475
#define _oidc_memset(b, c, __len) memset(b, c, __len)
7576
#define _oidc_memcpy(__dst, __src, __n) memcpy(__dst, __src, __n)
7677
#define _oidc_strcpy(__dst, __src) strcpy(__dst, __src)
78+
#define _oidc_strncpy(__dst, __src, __n) strncpy(__dst, __src, __n)
7779
#endif
7880

7981
static inline size_t _oidc_strlen(const char *s) {

0 commit comments

Comments
 (0)