Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apc_cache.c has two format specifier bugs (with patch) #501

Closed
gdt opened this issue Dec 6, 2023 · 1 comment
Closed

apc_cache.c has two format specifier bugs (with patch) #501

gdt opened this issue Dec 6, 2023 · 1 comment

Comments

@gdt
Copy link

gdt commented Dec 6, 2023

This file

  • uses %ld to print time_t
  • uses %ld to print zend_long, which can be uint32_t or uint64_t
--- apc_cache.c.orig    2023-11-11 17:35:28.000000000 +0000
+++ apc_cache.c
@@ -212,8 +212,8 @@ static void apc_cache_wlocked_gc(apc_cac
                                /* good ol' whining */
                                if (dead->ref_count > 0) {
                                        apc_debug(
-                                               "GC cache entry '%s' was on gc-list for %ld seconds",
-                                               ZSTR_VAL(dead->key), gc_sec
+                                               "GC cache entry '%s' was on gc-list for %jd seconds",
+                                               ZSTR_VAL(dead->key), (intmax_t) gc_sec
                                        );
                                }
 
@@ -275,7 +275,7 @@ PHP_APCU_API int APC_UNSERIALIZER_NAME(p
        BG(serialize_lock)--;
        
        if (!result) {
-               php_error_docref(NULL, E_NOTICE, "Error at offset %ld of %ld bytes", (zend_long)(tmp - buf), (zend_long)buf_len);
+               php_error_docref(NULL, E_NOTICE, "Error at offset " ZEND_LONG_FMT " of " ZEND_LONG_FMT " bytes", (zend_long)(tmp - buf), (zend_long)buf_len);
                ZVAL_NULL(value);
                return 0;
        }
@nikic nikic closed this as completed in 02b0ba7 Dec 9, 2023
@gdt
Copy link
Author

gdt commented Dec 10, 2023

Thanks for fixing these issues so quickly!

KitanoTom pushed a commit to link-u/apcu that referenced this issue Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant