Merge "Add {get,set}domainname(2)"
diff --git a/libc/arch-x86/atom/string/sse2-memset-atom.S b/libc/arch-x86/atom/string/sse2-memset-atom.S
index 30fb3f1..e03cd1a 100644
--- a/libc/arch-x86/atom/string/sse2-memset-atom.S
+++ b/libc/arch-x86/atom/string/sse2-memset-atom.S
@@ -113,11 +113,12 @@
#endif
ENTRY(__memset_chk)
- movl LEN(%esp), %ecx
- cmpl %ecx, CHK_DST_LEN(%esp)
- jbe memset
+ ENTRANCE
- jmp __memset_chk_fail
+ movl LEN(%esp), %ecx
+ cmpl CHK_DST_LEN(%esp), %ecx
+ ja __memset_chk_fail
+ jmp L(memset_length_loaded)
END(__memset_chk)
.section .text.sse2,"ax",@progbits
@@ -126,6 +127,7 @@
ENTRANCE
movl LEN(%esp), %ecx
+L(memset_length_loaded):
movzbl CHR(%esp), %eax
movb %al, %ah
/* Fill the whole EAX with pattern. */
diff --git a/libc/arch-x86/silvermont/string/sse2-memset-slm.S b/libc/arch-x86/silvermont/string/sse2-memset-slm.S
index 0718fa7..f5182ba 100644
--- a/libc/arch-x86/silvermont/string/sse2-memset-slm.S
+++ b/libc/arch-x86/silvermont/string/sse2-memset-slm.S
@@ -113,11 +113,12 @@
#endif
ENTRY(__memset_chk)
- movl LEN(%esp), %ecx
- cmpl %ecx, CHK_DST_LEN(%esp)
- jbe memset
+ ENTRANCE
- jmp __memset_chk_fail
+ movl LEN(%esp), %ecx
+ cmpl CHK_DST_LEN(%esp), %ecx
+ ja __memset_chk_fail
+ jmp L(memset_length_loaded)
END(__memset_chk)
.section .text.sse2,"ax",@progbits
@@ -126,6 +127,7 @@
ENTRANCE
movl LEN(%esp), %ecx
+L(memset_length_loaded):
cmp $0, %ecx
ja L(1byteormore)
SETRTNVAL
diff --git a/libc/bionic/clone.cpp b/libc/bionic/clone.cpp
index 9b5c9e7..af63977 100644
--- a/libc/bionic/clone.cpp
+++ b/libc/bionic/clone.cpp
@@ -47,6 +47,11 @@
void* new_tls = NULL;
int* child_tid = NULL;
+ if (!child_stack) {
+ errno = EINVAL;
+ return -1;
+ }
+
// Extract any optional parameters required by the flags.
va_list args;
va_start(args, arg);
diff --git a/libc/bionic/epoll_create.cpp b/libc/bionic/epoll_create.cpp
index 1dfafa8..74f664f 100644
--- a/libc/bionic/epoll_create.cpp
+++ b/libc/bionic/epoll_create.cpp
@@ -26,8 +26,13 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <sys/epoll.h>
-int epoll_create(int /*obsolete_size*/) {
+int epoll_create(int size) {
+ if (size <= 0) {
+ errno = EINVAL;
+ return -1;
+ }
return epoll_create1(0);
}
diff --git a/tests/getauxval_test.cpp b/tests/getauxval_test.cpp
index 6499f89..54458c4 100644
--- a/tests/getauxval_test.cpp
+++ b/tests/getauxval_test.cpp
@@ -67,7 +67,11 @@
// If this test fails, apps that use getauxval to decide at runtime whether crypto hardware is
// available will incorrectly assume that it isn't, and will have really bad performance.
// If this test fails, ensure that you've enabled COMPAT_BINFMT_ELF in your kernel configuration.
- ASSERT_NE(0UL, getauxval(AT_HWCAP2)) << "kernel not reporting AT_HWCAP2 to 32-bit ARM process";
+ // Note that 0 ("I don't support any of these things") is a legitimate response --- we need
+ // to check errno to see whether we got a "true" 0 or a "not found" 0.
+ errno = 0;
+ getauxval(AT_HWCAP2);
+ ASSERT_EQ(0, errno) << "kernel not reporting AT_HWCAP2 to 32-bit ARM process";
#else
GTEST_LOG_(INFO) << "This test is only meaningful for 32-bit ARM code.\n";
#endif
diff --git a/tests/sched_test.cpp b/tests/sched_test.cpp
index caf4c65..92d6c26 100644
--- a/tests/sched_test.cpp
+++ b/tests/sched_test.cpp
@@ -21,12 +21,12 @@
#include <sys/types.h>
#include <sys/wait.h>
-#if defined(__BIONIC__)
static int child_fn(void* i_ptr) {
*reinterpret_cast<int*>(i_ptr) = 42;
return 123;
}
+#if defined(__BIONIC__)
TEST(sched, clone) {
void* child_stack[1024];
@@ -59,6 +59,13 @@
ASSERT_EQ(EINVAL, errno);
}
+TEST(sched, clone_null_child_stack) {
+ int i = 0;
+ errno = 0;
+ ASSERT_EQ(-1, clone(child_fn, nullptr, CLONE_VM, &i));
+ ASSERT_EQ(EINVAL, errno);
+}
+
TEST(sched, cpu_set) {
cpu_set_t set;
diff --git a/tests/sys_epoll_test.cpp b/tests/sys_epoll_test.cpp
index 6e7a807..f6be4af 100644
--- a/tests/sys_epoll_test.cpp
+++ b/tests/sys_epoll_test.cpp
@@ -40,6 +40,12 @@
ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, &ss));
}
+TEST(sys_epoll, epoll_create_invalid_size) {
+ errno = 0;
+ ASSERT_EQ(-1, epoll_create(0));
+ ASSERT_EQ(EINVAL, errno);
+}
+
TEST(sys_epoll, epoll_event_data) {
int epoll_fd = epoll_create(1);
ASSERT_NE(-1, epoll_fd) << strerror(errno);