Also update the t testcases to cover this.
HChar* out_name = (HChar*)ARG2;
SizeT res = VG_(strlen)(VG_(resolved_exename));
res = VG_MIN(res, ARG3);
- VG_(strncpy)(out_name, VG_(resolved_exename), res);
- SET_STATUS_Success(res);
+ if (ML_(safe_to_deref)(out_name, res)) {
+ VG_(strncpy)(out_name, VG_(resolved_exename), res);
+ SET_STATUS_Success(res);
+ } else {
+ SET_STATUS_Failure(VKI_EFAULT);
+ }
fuse_may_block = False;
}
}
HChar* out_name = (HChar*)ARG3;
SizeT res = VG_(strlen)(VG_(resolved_exename));
res = VG_MIN(res, ARG4);
- VG_(strncpy)(out_name, VG_(resolved_exename), res);
- SET_STATUS_Success(res);
+ if (ML_(safe_to_deref)(out_name, res)) {
+ VG_(strncpy)(out_name, VG_(resolved_exename), res);
+ SET_STATUS_Success(res);
+ } else {
+ SET_STATUS_Failure(VKI_EFAULT);
+ }
fuse_may_block = False;
}
bug491394_LDADD = -lc
bug491394_LDFLAGS = -nostdlib -static
bug491394_CFLAGS = ${AM_CFLAGS} -Os
+bug514094_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_STRINGOP_OVERFLOW@
execve_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
if VGCONF_OS_IS_SOLARIS
fcntl_setown_LDADD = -lsocket -lnsl
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
+#include <errno.h>
#include "../../config.h"
int main(int argc, char** argv)
assert(strncmp(resolved, small_buf, 10) == 0);
assert(small_buf[10] == '#');
+#if defined(VGO_solaris)
+ ret = readlink("/proc/self/path/a.out", (char*)1, 100);
+#else
+ ret = readlink("/proc/self/exe", (char*)1, 100);
+#endif
+ assert(ret == -1);
+ assert(errno = EFAULT);
}
endif
clonev_LDADD = -lpthread
pthread_stack_LDADD = -lpthread
+readlinkat_self_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_STRINGOP_OVERFLOW@
stack_overflow_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ \
@FLAG_W_NO_INFINITE_RECURSION@
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
+#include <errno.h>
#include "../../config.h"
int main(int argc, char** argv)
char resolved[PATH_MAX];
realpath(argv[0], resolved);
assert(strcmp(resolved, buf) == 0);
+
+ const size_t small_buf_size = 11;
+ char small_buf[small_buf_size];
+ memset(small_buf, '#', small_buf_size);
+ ret = readlinkat(100, "/proc/self/exe", small_buf, 10);
+ assert(strncmp(resolved, small_buf, 10) == 0);
+ assert(small_buf[10] == '#');
+
+ ret = readlinkat(101, "/proc/self/exe", (char*)1, 100);
+ assert(ret == -1);
+ assert(errno = EFAULT);
}