env: Ensure that env_strncpy() always produces NULL-terminated string
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
358c529eff
commit
74bd0e3f7b
3
env/posix/ocf_env.h
vendored
3
env/posix/ocf_env.h
vendored
@ -618,7 +618,8 @@ static inline void env_sort(void *base, size_t num, size_t size,
|
|||||||
#define env_strnlen(s, smax) strnlen(s, smax)
|
#define env_strnlen(s, smax) strnlen(s, smax)
|
||||||
#define env_strncmp strncmp
|
#define env_strncmp strncmp
|
||||||
#define env_strncpy(dest, dmax, src, slen) ({ \
|
#define env_strncpy(dest, dmax, src, slen) ({ \
|
||||||
strncpy(dest, src, min(dmax, slen)); \
|
strncpy(dest, src, min(dmax - 1, slen)); \
|
||||||
|
dest[dmax - 1] = '\0'; \
|
||||||
0; \
|
0; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user