diff --git a/libc/Android.mk b/libc/Android.mk index a2a106aa7..d6c059929 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -725,7 +725,10 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_bionic_src_files) -LOCAL_CFLAGS := $(libc_common_cflags) -Werror +LOCAL_CFLAGS := $(libc_common_cflags) \ + -Werror \ + -Wframe-larger-than=2048 \ + LOCAL_CONLYFLAGS := $(libc_common_conlyflags) LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) diff --git a/libc/bionic/tmpfile.cpp b/libc/bionic/tmpfile.cpp index 8419ff529..602d40752 100644 --- a/libc/bionic/tmpfile.cpp +++ b/libc/bionic/tmpfile.cpp @@ -57,22 +57,23 @@ class ScopedSignalBlocker { }; static FILE* __tmpfile_dir(const char* tmp_dir) { - char buf[PATH_MAX]; - int path_length = snprintf(buf, sizeof(buf), "%s/tmp.XXXXXXXXXX", tmp_dir); - if (path_length >= static_cast(sizeof(buf))) { + char* path = NULL; + if (asprintf(&path, "%s/tmp.XXXXXXXXXX", tmp_dir) == -1) { return NULL; } int fd; { ScopedSignalBlocker ssb; - fd = mkstemp(buf); + fd = mkstemp(path); if (fd == -1) { + free(path); return NULL; } // Unlink the file now so that it's removed when closed. - unlink(buf); + unlink(path); + free(path); // Can we still use the file now it's unlinked? // File systems without hard link support won't have the usual Unix semantics.