diff --git a/auto/clang b/auto/clang index 27fe03b5a..95a60823f 100644 --- a/auto/clang +++ b/auto/clang @@ -172,6 +172,20 @@ njs_feature_test="__attribute__((no_sanitize(\"undefined\"))) int main(void) { . auto/feature +njs_feature="GCC __attribute__ nonstring" +njs_feature_name=NJS_HAVE_GCC_ATTRIBUTE_NONSTRING +njs_feature_run=no +njs_feature_incs= +njs_feature_libs= +njs_feature_test="int main(void) { + static const char str[3] __attribute__((nonstring)) = + \"ABC\"; + + return !!str[0]; + }" +. auto/feature + + njs_feature="Address sanitizer" njs_feature_name=NJS_HAVE_ADDRESS_SANITIZER njs_feature_run=no diff --git a/external/qjs_query_string_module.c b/external/qjs_query_string_module.c index bb7872292..1d8c637f4 100644 --- a/external/qjs_query_string_module.c +++ b/external/qjs_query_string_module.c @@ -537,7 +537,7 @@ qjs_string_encode(const uint32_t *escape, size_t size, const u_char *src, u_char *dst) { uint8_t byte; - static const u_char hex[16] = "0123456789ABCDEF"; + static const u_char hex[16] NJS_NONSTRING = "0123456789ABCDEF"; do { byte = *src++; diff --git a/src/njs_clang.h b/src/njs_clang.h index 2bd45a74f..da299a588 100644 --- a/src/njs_clang.h +++ b/src/njs_clang.h @@ -162,6 +162,14 @@ njs_leading_zeros64(uint64_t x) #endif +#if (NJS_HAVE_GCC_ATTRIBUTE_NONSTRING) +#define NJS_NONSTRING __attribute__((nonstring)) + +#else +#define NJS_NONSTRING +#endif + + #if (NJS_CLANG) /* Any __asm__ directive disables loop vectorization in GCC and Clang. */ #define njs_pragma_loop_disable_vectorization __asm__("") diff --git a/src/njs_sprintf.c b/src/njs_sprintf.c index 16ae9004e..d80fe396d 100644 --- a/src/njs_sprintf.c +++ b/src/njs_sprintf.c @@ -95,8 +95,8 @@ njs_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) njs_bool_t sign; njs_sprintf_t spf; - static const u_char hexadecimal[16] = "0123456789abcdef"; - static const u_char HEXADECIMAL[16] = "0123456789ABCDEF"; + static const u_char hexadecimal[16] NJS_NONSTRING = "0123456789abcdef"; + static const u_char HEXADECIMAL[16] NJS_NONSTRING = "0123456789ABCDEF"; static const u_char nan[] = "[nan]"; static const u_char infinity[] = "[infinity]"; diff --git a/src/njs_string.c b/src/njs_string.c index 6a91cb4c4..8cee00396 100644 --- a/src/njs_string.c +++ b/src/njs_string.c @@ -309,7 +309,7 @@ njs_encode_hex(njs_str_t *dst, const njs_str_t *src) size_t i, len; const u_char *start; - static const u_char hex[16] = "0123456789abcdef"; + static const u_char hex[16] NJS_NONSTRING = "0123456789abcdef"; len = src->length; start = src->start; diff --git a/src/njs_string.h b/src/njs_string.h index 686a5a74e..f48302788 100644 --- a/src/njs_string.h +++ b/src/njs_string.h @@ -209,7 +209,7 @@ njs_string_encode(const uint32_t *escape, size_t size, const u_char *src, u_char *dst) { uint8_t byte; - static const u_char hex[16] = "0123456789ABCDEF"; + static const u_char hex[16] NJS_NONSTRING = "0123456789ABCDEF"; do { byte = *src++; diff --git a/src/qjs_buffer.c b/src/qjs_buffer.c index a45f57ceb..a5cbf4c66 100644 --- a/src/qjs_buffer.c +++ b/src/qjs_buffer.c @@ -2354,7 +2354,7 @@ qjs_hex_encode(JSContext *ctx, const njs_str_t *src, njs_str_t *dst) size_t i, len; const u_char *start; - static const u_char hex[16] = "0123456789abcdef"; + static const u_char hex[16] NJS_NONSTRING = "0123456789abcdef"; len = src->length; start = src->start;