diff --git a/php/ext/google/protobuf/convert.c b/php/ext/google/protobuf/convert.c index 31deb742d7024..20f19084a12fa 100644 --- a/php/ext/google/protobuf/convert.c +++ b/php/ext/google/protobuf/convert.c @@ -432,7 +432,7 @@ void Convert_UpbToPhp(upb_MessageValue upb_val, zval* php_val, TypeInfo type, #else { char buf[21]; - int size = sprintf(buf, "%lld", upb_val.int64_val); + int size = snprintf(buf, sizeof(buf), "%lld", upb_val.int64_val); ZVAL_NEW_STR(php_val, zend_string_init(buf, size, 0)); } #endif @@ -443,7 +443,7 @@ void Convert_UpbToPhp(upb_MessageValue upb_val, zval* php_val, TypeInfo type, #else { char buf[21]; - int size = sprintf(buf, "%lld", (int64_t)upb_val.uint64_val); + int size = snprintf(buf, sizeof(buf), "%lld", (int64_t)upb_val.uint64_val); ZVAL_NEW_STR(php_val, zend_string_init(buf, size, 0)); } #endif