]> granicus.if.org Git - php/commitdiff
Fixed possible snprintf problem
authorMoriyoshi Koizumi <moriyoshi@php.net>
Mon, 10 Feb 2003 20:18:08 +0000 (20:18 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Mon, 10 Feb 2003 20:18:08 +0000 (20:18 +0000)
# besides snprintf returns int value, not uint / size_t...

main/SAPI.c

index 9657ba3a3fd01bc124f5a40dcd368e575d480e6c..dedd65c46275c636313f5cda014ea469aa134412 100644 (file)
@@ -720,12 +720,12 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
 
                if (call_user_function_ex(CG(function_table), NULL, &nm_zlib_get_coding_type, &uf_result, 0, NULL, 1, NULL TSRMLS_CC) != FAILURE && uf_result != NULL && Z_TYPE_P(uf_result) == IS_STRING) {
                        char buf[128];
-                       uint len;
+                       int len;
 
                        assert(Z_STRVAL_P(uf_result) != NULL);
 
                        len = snprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result));
-                       if (sapi_add_header(buf, len, 1)==FAILURE) {
+                       if (len <= 0 || sapi_add_header(buf, len, 1) == FAILURE) {
                                return FAILURE;
                        }
                        if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1) == FAILURE) {