[PATCH 2.2] fix ap_get_scoreboard_*

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 2.2] fix ap_get_scoreboard_*

Joe Orton
The limit checking is broken in 2.2's ap_get_scoreboard_*.  This was
fixed in 2.4 in http://svn.apache.org/viewvc?view=revision&revision=417252

Patch below backports that, plus fixes the additional broken comparison
in ap_get_scoreboard_lb(), discovered by Hisanobu Okuda.

Can I get +1s for this for 2.2?

Submitted by: wrowe, jorton

Index: server/scoreboard.c
===================================================================
--- server/scoreboard.c (revision 1799181)
+++ server/scoreboard.c (working copy)
@@ -503,8 +503,8 @@
 
 AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y)
 {
-    if (((x < 0) || (server_limit < x)) ||
-        ((y < 0) || (thread_limit < y))) {
+    if (((x < 0) || (x >= server_limit)) ||
+        ((y < 0) || (y >= thread_limit))) {
         return(NULL); /* Out of range */
     }
     return &ap_scoreboard_image->servers[x][y];
@@ -527,7 +527,7 @@
 
 AP_DECLARE(process_score *) ap_get_scoreboard_process(int x)
 {
-    if ((x < 0) || (server_limit < x)) {
+    if ((x < 0) || (x >= server_limit)) {
         return(NULL); /* Out of range */
     }
     return &ap_scoreboard_image->parent[x];
@@ -540,7 +540,7 @@
 
 AP_DECLARE(lb_score *) ap_get_scoreboard_lb(int lb_num)
 {
-    if (((lb_num < 0) || (lb_limit < lb_num))) {
+    if (lb_num < 0 || lb_num >= lb_limit) {
         return(NULL); /* Out of range */
     }
     return &ap_scoreboard_image->balancers[lb_num];

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2.2] fix ap_get_scoreboard_*

Yann Ylavic
On Mon, Jun 19, 2017 at 2:08 PM, Joe Orton <[hidden email]> wrote:
> The limit checking is broken in 2.2's ap_get_scoreboard_*.  This was
> fixed in 2.4 in http://svn.apache.org/viewvc?view=revision&revision=417252
>
> Patch below backports that, plus fixes the additional broken comparison
> in ap_get_scoreboard_lb(), discovered by Hisanobu Okuda.
>
> Can I get +1s for this for 2.2?

+1 by me (can't see the proposal in STATUS, though).
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2.2] fix ap_get_scoreboard_*

William A Rowe Jr
In reply to this post by Joe Orton
+1 here... That gets you to 3. Good catch thanks.

On Jun 19, 2017 07:09, "Joe Orton" <[hidden email]> wrote:
The limit checking is broken in 2.2's ap_get_scoreboard_*.  This was
fixed in 2.4 in http://svn.apache.org/viewvc?view=revision&revision=417252

Patch below backports that, plus fixes the additional broken comparison
in ap_get_scoreboard_lb(), discovered by Hisanobu Okuda.

Can I get +1s for this for 2.2?

Submitted by: wrowe, jorton

Index: server/scoreboard.c
===================================================================
--- server/scoreboard.c (revision 1799181)
+++ server/scoreboard.c (working copy)
@@ -503,8 +503,8 @@

 AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y)
 {
-    if (((x < 0) || (server_limit < x)) ||
-        ((y < 0) || (thread_limit < y))) {
+    if (((x < 0) || (x >= server_limit)) ||
+        ((y < 0) || (y >= thread_limit))) {
         return(NULL); /* Out of range */
     }
     return &ap_scoreboard_image->servers[x][y];
@@ -527,7 +527,7 @@

 AP_DECLARE(process_score *) ap_get_scoreboard_process(int x)
 {
-    if ((x < 0) || (server_limit < x)) {
+    if ((x < 0) || (x >= server_limit)) {
         return(NULL); /* Out of range */
     }
     return &ap_scoreboard_image->parent[x];
@@ -540,7 +540,7 @@

 AP_DECLARE(lb_score *) ap_get_scoreboard_lb(int lb_num)
 {
-    if (((lb_num < 0) || (lb_limit < lb_num))) {
+    if (lb_num < 0 || lb_num >= lb_limit) {
         return(NULL); /* Out of range */
     }
     return &ap_scoreboard_image->balancers[lb_num];

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2.2] fix ap_get_scoreboard_*

William A Rowe Jr
In reply to this post by Joe Orton
Joe, I compromised on your fix and retained parens for legibility,
following the pattern of the other fix.

Committed as r1799356, thanks

On Mon, Jun 19, 2017 at 7:08 AM, Joe Orton <[hidden email]> wrote:

> The limit checking is broken in 2.2's ap_get_scoreboard_*.  This was
> fixed in 2.4 in http://svn.apache.org/viewvc?view=revision&revision=417252
>
> Patch below backports that, plus fixes the additional broken comparison
> in ap_get_scoreboard_lb(), discovered by Hisanobu Okuda.
>
> Can I get +1s for this for 2.2?
>
> Submitted by: wrowe, jorton
>
> Index: server/scoreboard.c
> ===================================================================
> --- server/scoreboard.c (revision 1799181)
> +++ server/scoreboard.c (working copy)
> @@ -503,8 +503,8 @@
>
>  AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y)
>  {
> -    if (((x < 0) || (server_limit < x)) ||
> -        ((y < 0) || (thread_limit < y))) {
> +    if (((x < 0) || (x >= server_limit)) ||
> +        ((y < 0) || (y >= thread_limit))) {
>          return(NULL); /* Out of range */
>      }
>      return &ap_scoreboard_image->servers[x][y];
> @@ -527,7 +527,7 @@
>
>  AP_DECLARE(process_score *) ap_get_scoreboard_process(int x)
>  {
> -    if ((x < 0) || (server_limit < x)) {
> +    if ((x < 0) || (x >= server_limit)) {
>          return(NULL); /* Out of range */
>      }
>      return &ap_scoreboard_image->parent[x];
> @@ -540,7 +540,7 @@
>
>  AP_DECLARE(lb_score *) ap_get_scoreboard_lb(int lb_num)
>  {
> -    if (((lb_num < 0) || (lb_limit < lb_num))) {
> +    if (lb_num < 0 || lb_num >= lb_limit) {
>          return(NULL); /* Out of range */
>      }
>      return &ap_scoreboard_image->balancers[lb_num];
>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2.2] fix ap_get_scoreboard_*

Joe Orton
On Tue, Jun 20, 2017 at 11:48:53AM -0500, William A Rowe Jr wrote:
> Joe, I compromised on your fix and retained parens for legibility,
> following the pattern of the other fix.
>
> Committed as r1799356, thanks

Thanks a lot Bill!  I will survive the extra parentheses... :)