115 lines
4.1 KiB
Diff
115 lines
4.1 KiB
Diff
diff --git a/pmdk-1.4.2/src/examples/libpmemobj/array/array.c b/pmdk-1.4.2-edit/src/examples/libpmemobj/array/array.c
|
|
index 993ada2..68c422a 100644
|
|
--- a/src/examples/libpmemobj/array/array.c
|
|
+++ b/src/examples/libpmemobj/array/array.c
|
|
@@ -471,7 +471,7 @@ do_alloc(int argc, char *argv[])
|
|
POBJ_FREE(&array_info);
|
|
POBJ_ZNEW(pop, &array_info, struct array_info);
|
|
struct array_info *info = D_RW(array_info);
|
|
- strncpy(info->name, argv[0], MAX_BUFFLEN);
|
|
+ strncpy(info->name, argv[0], MAX_BUFFLEN - 1);
|
|
info->name[MAX_BUFFLEN - 1] = '\0';
|
|
info->size = size;
|
|
info->type = type;
|
|
diff --git a/pmdk-1.4.2/src/test/blk_rw/blk_rw.c b/pmdk-1.4.2-edit/src/test/blk_rw/blk_rw.c
|
|
index 484c442..cb0cf43 100644
|
|
--- a/src/test/blk_rw/blk_rw.c
|
|
+++ b/src/test/blk_rw/blk_rw.c
|
|
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
|
|
|
|
const char *path = argv[2];
|
|
|
|
- PMEMblkpool *handle;
|
|
+ PMEMblkpool *handle = NULL;
|
|
switch (*argv[3]) {
|
|
case 'c':
|
|
handle = pmemblk_create(path, Bsize, 0,
|
|
diff --git a/pmdk-1.4.2/src/test/obj_realloc/obj_realloc.c b/pmdk-1.4.2-edit/src/test/obj_realloc/obj_realloc.c
|
|
index 0264f12..3b12619 100644
|
|
--- a/src/test/obj_realloc/obj_realloc.c
|
|
+++ b/src/test/obj_realloc/obj_realloc.c
|
|
@@ -139,8 +139,8 @@ test_realloc(PMEMobjpool *pop, size_t size_from, size_t size_to,
|
|
|
|
UT_ASSERT(usable_size_from >= size_from);
|
|
|
|
- size_t check_size;
|
|
- uint16_t checksum;
|
|
+ size_t check_size = 0;
|
|
+ uint16_t checksum = 0;
|
|
|
|
if (zrealloc) {
|
|
UT_ASSERT(util_is_zeroed(D_RO(D_RO(root)->obj),
|
|
diff --git a/pmdk-1.4.2/src/test/rpmemd_db/rpmemd_db_test.c b/pmdk-1.4.2-edit/src/test/rpmemd_db/rpmemd_db_test.c
|
|
index 8e40a85..6535436 100644
|
|
--- a/src/test/rpmemd_db/rpmemd_db_test.c
|
|
+++ b/src/test/rpmemd_db/rpmemd_db_test.c
|
|
@@ -585,7 +585,7 @@ test_remove(const char *root_dir, const char *pool_desc)
|
|
struct rpmemd_db *db;
|
|
int ret;
|
|
char path[PATH_MAX];
|
|
- snprintf(path, PATH_MAX, "%s/%s", root_dir, pool_desc);
|
|
+ SNPRINTF(path, PATH_MAX, "%s/%s", root_dir, pool_desc);
|
|
|
|
fill_rand(&attr, sizeof(attr));
|
|
strncpy((char *)attr.poolset_uuid, "TEST", sizeof(attr.poolset_uuid));
|
|
diff --git a/pmdk-1.4.2/src/test/unittest/unittest.h b/pmdk-1.4.2-edit/src/test/unittest/unittest.h
|
|
index 6acc627..75abf2e 100644
|
|
--- a/src/test/unittest/unittest.h
|
|
+++ b/src/test/unittest/unittest.h
|
|
@@ -131,6 +131,13 @@ int ut_get_uuid_str(char *);
|
|
/* XXX - fix this temp hack dup'ing util_strerror when we get mock for win */
|
|
void ut_strerror(int errnum, char *buff, size_t bufflen);
|
|
|
|
+int ut_snprintf(const char *file, int line, const char *func,
|
|
+ char *str, size_t size, const char *format, ...);
|
|
+
|
|
+#define SNPRINTF(str, size, format, ...) \
|
|
+ ut_snprintf(__FILE__, __LINE__, __func__, \
|
|
+ str, size, format, __VA_ARGS__)
|
|
+
|
|
/* XXX - eliminate duplicated definitions in unittest.h and util.h */
|
|
#ifdef _WIN32
|
|
static inline int ut_util_statW(const wchar_t *path,
|
|
diff --git a/pmdk-1.4.2/src/test/unittest/Makefile b/pmdk-1.4.2-edit/src/test/unittest/Makefile
|
|
index a8a17da..96ae2d4 100644
|
|
--- a/src/test/unittest/Makefile
|
|
+++ b/src/test/unittest/Makefile
|
|
@@ -42,7 +42,7 @@ vpath %.h $(TOP)/src/common
|
|
|
|
TARGET = libut.a
|
|
OBJS = ut.o ut_alloc.o ut_file.o ut_pthread.o ut_signal.o ut_backtrace.o\
|
|
- os_posix.o os_thread_posix.o
|
|
+ os_posix.o os_thread_posix.o
|
|
CFLAGS = -I$(TOP)/src/include
|
|
CFLAGS += -I$(TOP)/src/common
|
|
CFLAGS += $(OS_INCS)
|
|
diff --git a/pmdk-1.4.2/src/test/unittest/ut.c b/pmdk-1.4.2-edit/src/test/unittest/ut.c
|
|
index 95fcd8f..9bb57e4 100644
|
|
--- a/src/test/unittest/ut.c
|
|
+++ b/src/test/unittest/ut.c
|
|
@@ -1003,3 +1003,24 @@ ut_toUTF16(const char *wstr)
|
|
return str;
|
|
}
|
|
#endif
|
|
+
|
|
+int
|
|
+ut_snprintf(const char *file, int line, const char *func,
|
|
+ char *str, size_t size, const char *format, ...)
|
|
+ {
|
|
+ va_list ap;
|
|
+ va_start(ap, format);
|
|
+ int ret = vsnprintf(str, size, format, ap);
|
|
+ va_end(ap);
|
|
+
|
|
+ if (ret < 0) {
|
|
+ if (!errno)
|
|
+ errno = EIO;
|
|
+ ut_fatal(file, line, func, "!snprintf");
|
|
+ } else if ((size_t)ret >= size) {
|
|
+ errno = ENOBUFS;
|
|
+ ut_fatal(file, line, func, "!snprintf");
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+ }
|