summaryrefslogtreecommitdiff
path: root/src/bin/common/opj_string.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/common/opj_string.h')
-rw-r--r--src/bin/common/opj_string.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/bin/common/opj_string.h b/src/bin/common/opj_string.h
index 8829926a..f704a8c9 100644
--- a/src/bin/common/opj_string.h
+++ b/src/bin/common/opj_string.h
@@ -39,34 +39,34 @@
/* keep in mind there still is a buffer read overflow possible */
static size_t opj_strnlen_s(const char *src, size_t max_len)
{
- size_t len;
-
- if (src == NULL) {
- return 0U;
- }
- for (len = 0U; (*src != '\0') && (len < max_len); src++, len++);
- return len;
+ size_t len;
+
+ if (src == NULL) {
+ return 0U;
+ }
+ for (len = 0U; (*src != '\0') && (len < max_len); src++, len++);
+ return len;
}
/* should be equivalent to C11 function except for the handler */
/* keep in mind there still is a buffer read overflow possible */
static int opj_strcpy_s(char* dst, size_t dst_size, const char* src)
{
- size_t src_len = 0U;
- if ((dst == NULL) || (dst_size == 0U)) {
- return EINVAL;
- }
- if (src == NULL) {
- dst[0] = '\0';
- return EINVAL;
- }
- src_len = opj_strnlen_s(src, dst_size);
- if (src_len >= dst_size) {
- return ERANGE;
- }
- memcpy(dst, src, src_len);
- dst[src_len] = '\0';
- return 0;
+ size_t src_len = 0U;
+ if ((dst == NULL) || (dst_size == 0U)) {
+ return EINVAL;
+ }
+ if (src == NULL) {
+ dst[0] = '\0';
+ return EINVAL;
+ }
+ src_len = opj_strnlen_s(src, dst_size);
+ if (src_len >= dst_size) {
+ return ERANGE;
+ }
+ memcpy(dst, src, src_len);
+ dst[src_len] = '\0';
+ return 0;
}
#endif /* OPJ_STRING_H */