Merge "Have pthread_attr_getstack for the main thread report RLIMIT_STACK..."
diff --git a/libc/arch-mips/string/mips_strlen.c b/libc/arch-mips/string/mips_strlen.c
index 9fb7e6a..45fc4b4 100644
--- a/libc/arch-mips/string/mips_strlen.c
+++ b/libc/arch-mips/string/mips_strlen.c
@@ -30,6 +30,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <string.h>
#include "mips-string-ops.h"
#define do_strlen_word(__av) {\
@@ -47,8 +48,8 @@
#define strlen my_strlen
#endif
-int
-strlen (const void *_a)
+size_t
+strlen (const char *_a)
{
int cnt = 0;
unsigned x;
diff --git a/libc/arch-x86/atom/string/sse2-wcslen-atom.S b/libc/arch-x86/atom/string/sse2-wcslen-atom.S
index 6a6ad51..2f10db4 100644
--- a/libc/arch-x86/atom/string/sse2-wcslen-atom.S
+++ b/libc/arch-x86/atom/string/sse2-wcslen-atom.S
@@ -65,21 +65,21 @@
ENTRY (wcslen)
mov STR(%esp), %edx
#endif
- cmp $0, (%edx)
+ cmpl $0, (%edx)
jz L(exit_tail0)
- cmp $0, 4(%edx)
+ cmpl $0, 4(%edx)
jz L(exit_tail1)
- cmp $0, 8(%edx)
+ cmpl $0, 8(%edx)
jz L(exit_tail2)
- cmp $0, 12(%edx)
+ cmpl $0, 12(%edx)
jz L(exit_tail3)
- cmp $0, 16(%edx)
+ cmpl $0, 16(%edx)
jz L(exit_tail4)
- cmp $0, 20(%edx)
+ cmpl $0, 20(%edx)
jz L(exit_tail5)
- cmp $0, 24(%edx)
+ cmpl $0, 24(%edx)
jz L(exit_tail6)
- cmp $0, 28(%edx)
+ cmpl $0, 28(%edx)
jz L(exit_tail7)
pxor %xmm0, %xmm0
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
index 079682c..c316151 100644
--- a/linker/debugger.cpp
+++ b/linker/debugger.cpp
@@ -170,9 +170,9 @@
if (info != NULL) {
// For a rethrown signal, this si_code will be right and the one debuggerd shows will
// always be SI_TKILL.
- snprintf(code_desc, sizeof(code_desc), ", code %d", info->si_code);
+ __libc_format_buffer(code_desc, sizeof(code_desc), ", code %d", info->si_code);
if (has_address) {
- snprintf(addr_desc, sizeof(addr_desc), ", fault addr %p", info->si_addr);
+ __libc_format_buffer(addr_desc, sizeof(addr_desc), ", fault addr %p", info->si_addr);
}
}
__libc_format_log(ANDROID_LOG_FATAL, "libc",
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 5f5823b..91ec49f 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -892,7 +892,21 @@
}
void do_android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size) {
- snprintf(buffer, buffer_size, "%s:%s", kDefaultLdPaths[0], kDefaultLdPaths[1]);
+ // Use basic string manipulation calls to avoid snprintf.
+ // snprintf indirectly calls pthread_getspecific to get the size of a buffer.
+ // When debug malloc is enabled, this call returns 0. This in turn causes
+ // snprintf to do nothing, which causes libraries to fail to load.
+ // See b/17302493 for further details.
+ // Once the above bug is fixed, this code can be modified to use
+ // snprintf again.
+ size_t required_len = strlen(kDefaultLdPaths[0]) + strlen(kDefaultLdPaths[1]) + 2;
+ if (buffer_size < required_len) {
+ __libc_fatal("android_get_LD_LIBRARY_PATH failed, buffer too small: buffer len %zu, required len %zu",
+ buffer_size, required_len);
+ }
+ char* end = stpcpy(buffer, kDefaultLdPaths[0]);
+ *end = ':';
+ strcpy(end + 1, kDefaultLdPaths[1]);
}
void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) {