Code Monkey home page Code Monkey logo

Comments (4)

crdumoul avatar crdumoul commented on June 9, 2024

Since I don't see any way to attach a file, I'll paste the patch here:


--- ngx_http_ajp_handler.c.orig 2011-02-12 00:44:33.000000000 -0500
+++ ngx_http_ajp_handler.c  2011-04-01 16:29:49.366773997 -0400
@@ -746,6 +746,8 @@
                     if (rc != NGX_OK) {
                         return NGX_ERROR;
                     }
+                    // account for the extra byte at the end of the chunk
+                    a->length++;
 
                     buf->pos += offset;
                     a->state = ngx_http_ajp_st_response_body_data_sending;
@@ -777,12 +779,13 @@
 
         ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->log, 0,
                 "input filter packet, length:%z, buffer_size:%z",
-                       a->length, ngx_buf_size(buf));
+                       a->length - 1, ngx_buf_size(buf));
 
         /* Get a zero length packet */
-        if (a->length == 0) {
+        if (a->length == 1) {
             if (buf->pos < buf->last) {
                 buf->pos++;
+                a->length--;
             }
 
             continue;
@@ -828,8 +831,8 @@
 
         /* STUB */ b->num = buf->num;
 
-        if (buf->pos + a->length < buf->last) {
-            buf->pos += a->length;
+        if (buf->pos + a->length <= buf->last) {
+            buf->pos += (a->length - 1);
             b->last = buf->pos;
 
             /* The last byte of this message always seems to be

from nginx_ajp_module.

yaoweibin avatar yaoweibin commented on June 9, 2024

Thanks for this excellent bug report, Chris, you are such a good hacker.

I have added a patch for this module. But it's a little different from yours. I think the length is the meaning of ajp data packet. It should not add a one-extra byte in the length which may confuse its true meaning. So I add a new member of extra_zero_byte in the struct of ngx_http_ajp_ctx_t.

The commit is here: 1445606

I have not tested fully with this patch. Can you check out this experiment branch and test it. Thank you very much. The branch is here:
https://github.com/yaoweibin/nginx_ajp_module/commits/experiment

from nginx_ajp_module.

crdumoul avatar crdumoul commented on June 9, 2024

Hi yaoweibin,
I've looked at your commit, and I see one potential problem. The new member extra_zero_byte isn't initialized to zero anywhere. I think a line like:

a->extra_zero_byte = 0;

needs to be added in the function ngx_http_ajp_reinit_request().

Also, in this "if" statement:

        /* Get a zero length packet */
        if (a->length == 0 && a->extra_zero_byte && (buf->pos < buf->last)) {
            if (buf->pos < buf->last) {
                buf->pos++;
                a->extra_zero_byte = 0;
            }

            continue;
        }

the inner "if" is redundant.

from nginx_ajp_module.

yaoweibin avatar yaoweibin commented on June 9, 2024

Thanks for your opinion, Chris. I think you are right. I have fixed this problem in the experiment branch.

from nginx_ajp_module.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.