🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

26 total messages Started by Arne Vajhøj Thu, 19 Nov 2026 21:25
More PHP vulnerabilities
#218
Author: Arne Vajhøj
Date: Thu, 19 Nov 2026 21:25
35 lines
1903 bytes
They released a bunch of fixes today.

One of them is easy to demo on VMS:

$ type another.php
<?php

$sslctxopts= [
     'ssl' => [
         'verify_peer'=> false,
         'verify_peer_name'=> false,
     ],
];
echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
//echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false, 
stream_context_create($sslctxopts)) . "\n";
echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";

?>
$ php another.php
Port = 80
Port = 443
Port = 80
Port = 80

WTF????

reveal.aspx contains:

Port = <%= Request.Url.Port %>

Arne
Re: More PHP vulnerabilities
#219
Author: Arne Vajhøj
Date: Thu, 19 Nov 2026 23:43
45 lines
2502 bytes
On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
> They released a bunch of fixes today.
> 
> One of them is easy to demo on VMS:
> 
> $ type another.php
> <?php
> 
> $sslctxopts= [
>      'ssl' => [
>          'verify_peer'=> false,
>          'verify_peer_name'=> false,
>      ],
> ];
> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false, 
> stream_context_create($sslctxopts)) . "\n";
> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> 
> ?>
> $ php another.php
> Port = 80
> Port = 443
> Port = 80
> Port = 80
> 
> WTF????
> 
> reveal.aspx contains:
> 
> Port = <%= Request.Url.Port %>
Two notes:
1) Despite the name then file_get_contents can also
    be used for POST requests (sending data out)
2) The entire feature can be disabled in php.ini by
    setting allow_url_fopen to off, but that is not
    expected to be necessary

Anyway I will recommend anyone needing to do HTTP requests
in PHP to use the curl extension instead of file_get_contents.

Arne
Re: More PHP vulnerabilities
#224
Author: Arne Vajhøj
Date: Fri, 20 Nov 2026 12:49
24 lines
1993 bytes
On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false, 
> stream_context_create($sslctxopts)) . "\n";
> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";

> $ php another.php
> Port = 80
> Port = 443
> Port = 80
> Port = 80
And for the curious - before fix:

use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) && 
ZSTR_VAL(resource->scheme)[4] == 's';

and after:

use_ssl = zend_string_equals_literal_ci(resource->scheme, "https");

Arne
Re: More PHP vulnerabilities
#225
Author: Simon Clubley
Date: Fri, 20 Nov 2026 20:10
34 lines
2419 bytes
On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false, 
>> stream_context_create($sslctxopts)) . "\n";
>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>
>> $ php another.php
>> Port = 80
>> Port = 443
>> Port = 80
>> Port = 80
> And for the curious - before fix:
>
> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) && 
> ZSTR_VAL(resource->scheme)[4] == 's';
>

I really hope that line was always compiled by a short-circuiting
compiler and that line always successfully triggered short-circuiting...

Don't be surprised if everyone is now looking for similar constructs
that rely on short-circuiting to be safe.

And yes, I know it's read-only. That's not the point. That's _seriously_
not the point.

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
Re: More PHP vulnerabilities
#226
Author: Arne Vajhøj
Date: Fri, 20 Nov 2026 20:24
29 lines
2437 bytes
On 11/20/2026 3:10 PM, Simon Clubley wrote:
> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false,
>>> stream_context_create($sslctxopts)) . "\n";
>>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>
>>> $ php another.php
>>> Port = 80
>>> Port = 443
>>> Port = 80
>>> Port = 80
>> And for the curious - before fix:
>>
>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>> ZSTR_VAL(resource->scheme)[4] == 's';
> 
> I really hope that line was always compiled by a short-circuiting
> compiler and that line always successfully triggered short-circuiting...
> 
> Don't be surprised if everyone is now looking for similar constructs
> that rely on short-circuiting to be safe.
Doesn't C require/mandate short circuiting in cases like this??

Arne
Re: More PHP vulnerabilities
#227
Author: Dan Cross
Date: Fri, 20 Nov 2026 20:28
35 lines
2262 bytes
In article <11dqa7g$3guqc$1@dont-email.me>,
Arne Vajhøj <arne@vajhoej.dk> wrote:
>On 11/20/2026 3:10 PM, Simon Clubley wrote:
>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>>>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false,
>>>> stream_context_create($sslctxopts)) . "\n";
>>>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>
>>>> $ php another.php
>>>> Port = 80
>>>> Port = 443
>>>> Port = 80
>>>> Port = 80
>>> And for the curious - before fix:
>>>
>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>
>> I really hope that line was always compiled by a short-circuiting
>> compiler and that line always successfully triggered short-circuiting...
>>
>> Don't be surprised if everyone is now looking for similar constructs
>> that rely on short-circuiting to be safe.
>
>Doesn't C require/mandate short circuiting in cases like this??

Yes.  `&&` and `||` are both short-circuiting operators in C and
have always been so.

	- Dan C.
Re: More PHP vulnerabilities
#228
Author: Arne Vajhøj
Date: Sat, 21 Nov 2026 22:32
98 lines
3290 bytes
On 11/20/2026 3:24 PM, Arne Vajhøj wrote:
> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>> And for the curious - before fix:
>>>
>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>
>> I really hope that line was always compiled by a short-circuiting
>> compiler and that line always successfully triggered short-circuiting...
>>
>> Don't be surprised if everyone is now looking for similar constructs
>> that rely on short-circuiting to be safe.
 >
> Doesn't C require/mandate short circuiting in cases like this??
I believe the VMS landscape looks like:

              Undefined(*) L to R    L to R
                           all       short circuit
VMS Fortran  .and.
              .or.
VMS Pascal   and                    and_then
              or                     or_else
C                         &         &&
                           |         ||
Ada          and                    and then
              or                     or else
Java                      &         &&
                           |         ||
Python                    &         and
                           |         or
PHP                       &         &&
                           |         ||
                                     and(**)
                                     or(**)

*)  do not use with anything with side effects
**) do not use ever

Example of undefined with VMS Pascal and /OPT vs /NOOPT:

$ type demo.pas
program demo(input,output);

function ff : boolean;

begin
    writeln('ff');
    ff := false;
end;

function tf : boolean;

begin
    writeln('tf');
    tf := true;
end;

var
    res : boolean;

begin
    res := ff and tf;
    writeln('ff and tf', res);
    res := ff and_then tf;
    writeln('ff and_then tf', res);
    res := tf or ff;
    writeln('tf or ff', res);
    res := tf or_else ff;
    writeln('tf or_else ff', res);
end.
$ pas demo
$ lin demo
$ r demo
ff
ff and tf FALSE
ff
ff and_then tf FALSE
tf
tf or ff  TRUE
tf
tf or_else ff  TRUE
$ pas/noop demo
$ lin demo
$ r demo
ff
tf
ff and tf FALSE
ff
ff and_then tf FALSE
tf
ff
tf or ff  TRUE
tf
tf or_else ff  TRUE

Arne
Re: More PHP vulnerabilities
#229
Author: Arne Vajhøj
Date: Sat, 21 Nov 2026 22:49
34 lines
1824 bytes
On 11/21/2026 5:32 PM, Arne Vajhøj wrote:
> PHP                       &         &&
>                            |         ||
>                                      and(**)
>                                      or(**)

> **) do not use ever
And in case somebody wonder.

$ php crazy.php
False
True
True False
$ clean
$ type crazy.php
<?php

$a = True;
$b = False;
$c = $a && $b;
echo sprintf("%s\n", $c ? 'True' : 'False');
$c = $a and $b;
echo sprintf("%s\n", $c ? 'True' : 'False');
$c2 = ($c1 = $a and $b);
echo sprintf("%s %s\n", $c1 ? 'True' : 'False', $c2 ? 'True' : 'False');

?>
$ php crazy.php
False
True
True False

Arne
Re: More PHP vulnerabilities
#230
Author: Dan Cross
Date: Sat, 21 Nov 2026 23:58
65 lines
2820 bytes
In article <6b021bab$0$672$14726298@news.sunsite.dk>,
Arne Vajhøj <arne@vajhoej.dk> wrote:
>On 11/20/2026 3:24 PM, Arne Vajhøj wrote:
>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>> [snip]
>> Doesn't C require/mandate short circuiting in cases like this??
>
>I believe the VMS landscape looks like:
>
>              Undefined(*) L to R    L to R
>                           all       short circuit
> [snip]
>VMS Fortran  .and.
>              .or.
>VMS Pascal   and                    and_then
>              or                     or_else
>C                         &         &&
>                           |         ||
>Ada          and                    and then
>              or                     or else
>Java                      &         &&
>                           |         ||
>Python                    &         and
>                           |         or
>PHP                       &         &&
>                           |         ||
>                                     and(**)
>                                     or(**)
>[snip]

For C, Java, Python, and (probably?) PHP, you are mixing up
different categories of operators: `&` and `|` are bitwise
operators in those languages, while `&&` and `||` are boolean
operators.  Since they are intended to do differnt things, the
semantics are different.

I doubt that there are many many languages that would introduce
short-circuiting behavior for bitwise operators.  But note also
that we may see behaviors like this:

```c
	#include <stdio.h>
	int
	main(void)
	{
		int a = 1, b = 2;

		if (a)
			printf("a is true\n");
		if (b)
			printf("b is true\n");
		if (a & b)
			printf("both are true\n");
		else
			printf("but `&` is not a boolean operator\n");

		return 0;
	}
```

Moral of the story: don't lump boolean and bitwise operators
together like they are the same thing.

	- Dan C.
Re: More PHP vulnerabilities
#231
Author: Lawrence D’Oliveiro
Date: Sun, 22 Nov 2026 01:13
13 lines
1678 bytes
On Sat, 21 Nov 2026 17:32:01 -0500, Arne Vajhøj wrote:

> PHP                       &         &&
>                            |         ||
>                                      and(**)
>                                      or(**)
>
> **) do not use ever

How many things are there in PHP that one might classify as “do not
use ever”?

Here’s another one: “+” on arrays. Yes, it’s defined. Defined as what?
Re: More PHP vulnerabilities
#232
Author: Arne Vajhøj
Date: Sun, 22 Nov 2026 01:25
111 lines
4249 bytes
On 11/21/2026 6:58 PM, Dan Cross wrote:
> In article <6b021bab$0$672$14726298@news.sunsite.dk>,
> Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 11/20/2026 3:24 PM, Arne Vajhøj wrote:
>>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>>> [snip]
>>> Doesn't C require/mandate short circuiting in cases like this??
>>
>> I believe the VMS landscape looks like:
>>
>>               Undefined(*) L to R    L to R
>>                            all       short circuit
>> [snip]
>> VMS Fortran  .and.
>>               .or.
>> VMS Pascal   and                    and_then
>>               or                     or_else
>> C                         &         &&
>>                            |         ||
>> Ada          and                    and then
>>               or                     or else
>> Java                      &         &&
>>                            |         ||
>> Python                    &         and
>>                            |         or
>> PHP                       &         &&
>>                            |         ||
>>                                      and(**)
>>                                      or(**)
>> [snip]
> 
> For C, Java, Python, and (probably?) PHP, you are mixing up
> different categories of operators: `&` and `|` are bitwise
> operators in those languages, while `&&` and `||` are boolean
> operators.  Since they are intended to do differnt things, the
> semantics are different.

Those 4 are a bit different.

Java has both bitwise & and | on integer types and logical & and | on
booleans.

In C and Python bool are sort of an int so bitwise and logical
are the same.

PHP just auto converts booleans to ints for bitwise operator.

But all 4 quacks like a duck.

> I doubt that there are many many languages that would introduce
> short-circuiting behavior for bitwise operators.  But note also
> that we may see behaviors like this:
> 
> ```c
> 	#include <stdio.h>
> 	int
> 	main(void)
> 	{
> 		int a = 1, b = 2;
> 
> 		if (a)
> 			printf("a is true\n");
> 		if (b)
> 			printf("b is true\n");
> 		if (a & b)
> 			printf("both are true\n");
> 		else
> 			printf("but `&` is not a boolean operator\n");
> 
> 		return 0;
> 	}
> ```
Good point.

The problem here is the use of int instead of bool.

#include <stdio.h>
#include <stdbool.h>

int main()
{
     bool a = 1, b = 2;

     if (a)
         printf("a is true\n");
     if (b)
         printf("b is true\n");
     if (a & b)
         printf("both are true\n");
     else
         printf("but `&` is not a boolean operator\n");

     return 0;
}

Outputs a different result.

But treating int's as booleans is an integrated part
of C.

And it has spilled over to many other languages.

So yes - if working with int's instead of bool's,
then bitwise operators can not be used as logical
operators.

Arne



Re: More PHP vulnerabilities
#233
Author: Arne Vajhøj
Date: Sun, 22 Nov 2026 01:38
75 lines
2337 bytes
On 11/21/2026 8:13 PM, Lawrence D’Oliveiro wrote:
> On Sat, 21 Nov 2026 17:32:01 -0500, Arne Vajhøj wrote:
> 
>> PHP                       &         &&
>>                             |         ||
>>                                       and(**)
>>                                       or(**)
>>
>> **) do not use ever
> 
> How many things are there in PHP that one might classify as “do not
> use ever”?

Several.

> Here’s another one: “+” on arrays. Yes, it’s defined. Defined as what?

It merges arrays. With slightly different semantics than array_merge.

I think it mostly makes sense for associative arrays. It is weird for
indexed arrays.

$ type crazy2.php
<?php

$a = [ 'A' => 1, 'B' => 2, 'C' => 3 ];
$b = [ 'C' => 4, 'D' => 5 ];
$c = $a + $b;
print_r($c);
$d = array_merge($a, $b);
print_r($d);

?>
$ php crazy2.php
Array
(
     [A] => 1
     [B] => 2
     [C] => 3
     [D] => 5
)
Array
(
     [A] => 1
     [B] => 2
     [C] => 4
     [D] => 5
)

$ type crazy3.php
<?php

$a = [ 'A' ];
$b = [ 'B', 'C' ];
$c = $a + $b;
print_r($c);
$d = array_merge($a, $b);
print_r($d);

?>
$ php crazy3.php
Array
(
     [0] => A
     [1] => C
)
Array
(
     [0] => A
     [1] => B
     [2] => C
)

Arne
Re: More PHP vulnerabilities
#234
Author: Lawrence D’Oliveiro
Date: Sun, 22 Nov 2026 01:47
14 lines
1819 bytes
On Sat, 21 Nov 2026 20:25:26 -0500, Arne Vajhøj wrote:

> Java has both bitwise & and | on integer types and logical & and |
> on booleans.
>
> In C and Python bool are sort of an int so bitwise and logical are
> the same.

Python treats bool as a subclass of int. (Yes, you can subclass int.)

Java tries to treat them as entirely separate types, which is not
necessarily a bad thing on its own, but then it doesn’t provide
natural conversions between them. Like being able to use bool for
indexing arrays, just for example.
Re: More PHP vulnerabilities
#235
Author: Arne Vajhøj
Date: Sun, 22 Nov 2026 01:55
27 lines
2176 bytes
On 11/21/2026 8:47 PM, Lawrence D’Oliveiro wrote:
> On Sat, 21 Nov 2026 20:25:26 -0500, Arne Vajhøj wrote:
> 
>> Java has both bitwise & and | on integer types and logical & and |
>> on booleans.
>>
>> In C and Python bool are sort of an int so bitwise and logical are
>> the same.
> 
> Python treats bool as a subclass of int. (Yes, you can subclass int.)
> 
> Java tries to treat them as entirely separate types, which is not
> necessarily a bad thing on its own,

We are some that like type safety.

:-)

>                                     but then it doesn’t provide
> natural conversions between them. Like being able to use bool for
> indexing arrays, just for example.

It would have to be a[bv ? 1 : 0] or use a Map<Boolean,X> instead
of X[].

Arne
Re: More PHP vulnerabilities
#236
Author: Dan Cross
Date: Sun, 22 Nov 2026 05:43
168 lines
5691 bytes
In article <11dtg8h$isan$1@dont-email.me>,
Arne Vajhøj <arne@vajhoej.dk> wrote:
>On 11/21/2026 6:58 PM, Dan Cross wrote:
>> In article <6b021bab$0$672$14726298@news.sunsite.dk>,
>> Arne Vajhøj <arne@vajhoej.dk> wrote:
>>> On 11/20/2026 3:24 PM, Arne Vajhøj wrote:
>>>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>>>> [snip]
>>>> Doesn't C require/mandate short circuiting in cases like this??
>>>
>>> I believe the VMS landscape looks like:
>>>
>>>               Undefined(*) L to R    L to R
>>>                            all       short circuit
>>> [snip]
>>> VMS Fortran  .and.
>>>               .or.
>>> VMS Pascal   and                    and_then
>>>               or                     or_else
>>> C                         &         &&
>>>                            |         ||
>>> Ada          and                    and then
>>>               or                     or else
>>> Java                      &         &&
>>>                            |         ||
>>> Python                    &         and
>>>                            |         or
>>> PHP                       &         &&
>>>                            |         ||
>>>                                      and(**)
>>>                                      or(**)
>>> [snip]
>>
>> For C, Java, Python, and (probably?) PHP, you are mixing up
>> different categories of operators: `&` and `|` are bitwise
>> operators in those languages, while `&&` and `||` are boolean
>> operators.  Since they are intended to do differnt things, the
>> semantics are different.
>
>Those 4 are a bit different.
>
>Java has both bitwise & and | on integer types and logical & and | on
>booleans.

Eh...kinda.  It's true that Java has well-defined bitwise
operators on booleans, but it's really just expressing the
integer rules for a type that can only have two values.  It's
still a bitwise-operation.

>In C and Python bool are sort of an int so bitwise and logical
>are the same.
>
>PHP just auto converts booleans to ints for bitwise operator.
>
>But all 4 quacks like a duck.
>
>> I doubt that there are many many languages that would introduce
>> short-circuiting behavior for bitwise operators.  But note also
>> that we may see behaviors like this:
>>
>> ```c
>> 	#include <stdio.h>
>> 	int
>> 	main(void)
>> 	{
>> 		int a = 1, b = 2;
>>
>> 		if (a)
>> 			printf("a is true\n");
>> 		if (b)
>> 			printf("b is true\n");
>> 		if (a & b)
>> 			printf("both are true\n");
>> 		else
>> 			printf("but `&` is not a boolean operator\n");
>>
>> 		return 0;
>> 	}
>> ```
>
>Good point.
>
>The problem here is the use of int instead of bool.

Incorrect.

>#include <stdio.h>
>#include <stdbool.h>
>
>int main()
>{
>     bool a = 1, b = 2;

This does not do what you think that it does.

>     if (a)
>         printf("a is true\n");
>     if (b)
>         printf("b is true\n");
>     if (a & b)
>         printf("both are true\n");
>     else
>         printf("but `&` is not a boolean operator\n");
>
>     return 0;
>}
>
>Outputs a different result.

Because in this case, `a` and `b` are both equal to (integer) 1.
The assignment `bool b = 2` sets `b` to `true` (any non-zero
integer constant is "true" in a boolean context in C), and
`true` has the value 1 (C23, sec 6.4.4.6, para 3).

An object of type `bool` in C has exactly one value-holding bit,
and `sizeof(bool)*CHAR_BIT-1` padding bits (C23, sec 6.2.6.2,
para 1).

When applied to a bitwise operator like `&` or `|`, both `a` and
`b` will first be converted to a (signed) `int` based on the
rank of the `bool` type and the rules for integer promotions
(C23, sec 6.3.1.1).

```
term% cat bitwise.c
#include <stdbool.h>
#include <stdio.h>
int
main(void)
{
        bool a = 1, b = 2;
        if (a)
                printf("a is true\n");
        if (b)
                printf("b is true\n");
        if (a & b)
                printf("both are true (a = %d, b = %d)\n", a, b);
        else
                printf("but `&` is not a boolean operator\n");
        return 0;
}
term% make bitwise
cc -O2 -pipe    -o bitwise bitwise.c
term% ./bitwise
a is true
b is true
both are true (a = 1, b = 1)
term%
```

>But treating int's as booleans is an integrated part
>of C.

In C, `bool` is an integer type.  The usual arithmetic
conversions apply, including the integer promotion rules.

>And it has spilled over to many other languages.
>
>So yes - if working with int's instead of bool's,
>then bitwise operators can not be used as logical
>operators.

No.  In all cases, bitwise operators are doing bitwise
operations.  They are simply not boolean operators, even if
applied to boolean values.

	- Dan C.
Re: More PHP vulnerabilities
#237
Author: Bill Gunshannon
Date: Sun, 22 Nov 2026 13:27
22 lines
1559 bytes
On 11/21/26 20:13, Lawrence D’Oliveiro wrote:
> On Sat, 21 Nov 2026 17:32:01 -0500, Arne Vajhøj wrote:
> 
>> PHP                       &         &&
>>                             |         ||
>>                                       and(**)
>>                                       or(**)
>>
>> **) do not use ever
> 
> How many things are there in PHP that one might classify as “do not
> use ever”?

The whole language?

> 
> Here’s another one: “+” on arrays. Yes, it’s defined. Defined as what?



bill
Re: More PHP vulnerabilities
#238
Author: Simon Clubley
Date: Mon, 23 Nov 2026 19:42
52 lines
3407 bytes
On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>>>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false,
>>>> stream_context_create($sslctxopts)) . "\n";
>>>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>
>>>> $ php another.php
>>>> Port = 80
>>>> Port = 443
>>>> Port = 80
>>>> Port = 80
>>> And for the curious - before fix:
>>>
>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>> ZSTR_VAL(resource->scheme)[4] == 's';
>> 
>> I really hope that line was always compiled by a short-circuiting
>> compiler and that line always successfully triggered short-circuiting...
>> 
>> Don't be surprised if everyone is now looking for similar constructs
>> that rely on short-circuiting to be safe.
> Doesn't C require/mandate short circuiting in cases like this??
>

As Dan has pointed out, yes. However, I absolutely hate that style of
coding (and the use of short circuiting in general) - it is way too fragile.

It depends on the compiler behaving as expected and it depends on someone
not making some edit change that happens to have the unexpected side-effect
of disabling any working short circuiting.

Seriously. Please consider not using short circuiting and instead writing
your code so it works regardless of whether your compiler short-circuits
or not. (Or it suddenly decides to stop short-circuiting one day).

Oh, and before you all start mocking me, please read this:

https://www.redhat.com/en/blog/security-flaws-caused-compiler-optimizations

Even Linux has been caught out in the past by compilers not behaving
as expected.

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
Re: More PHP vulnerabilities
#239
Author: Scott Lurndal
Date: Mon, 23 Nov 2026 20:18
60 lines
3324 bytes
Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> writes:
>On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>>>>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false,
>>>>> stream_context_create($sslctxopts)) . "\n";
>>>>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>
>>>>> $ php another.php
>>>>> Port = 80
>>>>> Port = 443
>>>>> Port = 80
>>>>> Port = 80
>>>> And for the curious - before fix:
>>>>
>>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>> 
>>> I really hope that line was always compiled by a short-circuiting
>>> compiler and that line always successfully triggered short-circuiting...
>>> 
>>> Don't be surprised if everyone is now looking for similar constructs
>>> that rely on short-circuiting to be safe.
>> Doesn't C require/mandate short circuiting in cases like this??
>>
>
>As Dan has pointed out, yes. However, I absolutely hate that style of
>coding (and the use of short circuiting in general) - it is way too fragile.

Must disagree.  Consider the classic  (ptr && *ptr) paradigm.

>
>It depends on the compiler behaving as expected

No, it depends on the programmer being familiar with
the C (and C++) language grammar.

The chance that any C compiler (outside of a first year college
course) would not properly handle those operators correctly
is exactly zero.


>Seriously. Please consider not using short circuiting and instead writing
>your code so it works regardless of whether your compiler short-circuits
>or not. (Or it suddenly decides to stop short-circuiting one day).

Seriously, use the conditonal logical operators frequently and
often.  They'll work correctly unto the heat death of the universe.

>
>Oh, and before you all start mocking me, please read this:
>
>https://www.redhat.com/en/blog/security-flaws-caused-compiler-optimizations

That has nothing to do with the conditional-and/or operators.
Re: More PHP vulnerabilities
#240
Author: Simon Clubley
Date: Mon, 23 Nov 2026 20:58
56 lines
3216 bytes
On 2026-11-23, Scott Lurndal <scott@slp53.sl.home> wrote:
> Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> writes:
>>>
>>
>>As Dan has pointed out, yes. However, I absolutely hate that style of
>>coding (and the use of short circuiting in general) - it is way too fragile.
>
> Must disagree.  Consider the classic  (ptr && *ptr) paradigm.
>
>>
>>It depends on the compiler behaving as expected
>
> No, it depends on the programmer being familiar with
> the C (and C++) language grammar.
>

Or the programmer is familiar with it but doesn't like it in the same
way that he doesn't like in-band null string terminators or (in C++)
he doesn't like the decision for default speed over safety ([] is unchecked
instead of checked and you have to use at() for safe access).

All those are examples of my mindset here BTW. In that latter case, you
should have got safety by default and if you wanted speed you should have
had to ask for it.

> The chance that any C compiler (outside of a first year college
> course) would not properly handle those operators correctly
> is exactly zero.
>

As in my original posting, the problem could also be introduced at
application level during an edit.

>
>>Seriously. Please consider not using short circuiting and instead writing
>>your code so it works regardless of whether your compiler short-circuits
>>or not. (Or it suddenly decides to stop short-circuiting one day).
>
> Seriously, use the conditonal logical operators frequently and
> often.  They'll work correctly unto the heat death of the universe.
>
>>
>>Oh, and before you all start mocking me, please read this:
>>
>>https://www.redhat.com/en/blog/security-flaws-caused-compiler-optimizations
>
> That has nothing to do with the conditional-and/or operators.
>

It does if you understand the point I am trying to make.

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
Re: More PHP vulnerabilities
#241
Author: Arne Vajhøj
Date: Mon, 23 Nov 2026 21:38
59 lines
3225 bytes
On 11/23/2026 2:42 PM, Simon Clubley wrote:
> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>> And for the curious - before fix:
>>>>
>>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>>
>>> I really hope that line was always compiled by a short-circuiting
>>> compiler and that line always successfully triggered short-circuiting...

>> Doesn't C require/mandate short circuiting in cases like this??
>>
> 
> As Dan has pointed out, yes. However, I absolutely hate that style of
> coding (and the use of short circuiting in general) - it is way too fragile.
> 
> It depends on the compiler behaving as expected and it depends on someone
> not making some edit change that happens to have the unexpected side-effect
> of disabling any working short circuiting.
> 
> Seriously. Please consider not using short circuiting and instead writing
> your code so it works regardless of whether your compiler short-circuits
> or not. (Or it suddenly decides to stop short-circuiting one day).
In general coding to protect against potential compiler
bugs seems futile to me.

Compiler bugs does happen, but this seems like a very
unlikely one to happen.

I know unlikely <> impossible, but preparing for
unlikely compiler bugs does not make sense to me.

I would be more attracted to the readability argument.

That:

IF e1 AND e2 THEN
     ...
END IF

would be more readable as:

IF e1 THEN
     IF e2 THEN
         ...
     END IF
END IF

Because even though it seems highly unlikely that compiler writers
does not know the rules for short circuit in the language they are
implementing, then it could definitely happen that the
application writer using the compiler does not.

Arne


Re: More PHP vulnerabilities
#242
Author: Lawrence D’Oliveiro
Date: Mon, 23 Nov 2026 22:46
19 lines
1671 bytes
On Mon, 23 Nov 2026 16:38:33 -0500, Arne Vajhøj wrote:

> That:
>
> IF e1 AND e2 THEN
>      ...
> END IF
>
> would be more readable as:
>
> IF e1 THEN
>      IF e2 THEN
>          ...
>      END IF
> END IF

Ada had “and then” and “or else” to explicitly specify short-circuit
evaluation. And the Algol 68 revival is proposing something similar
<https://algol68-lang.org/>.
Re: More PHP vulnerabilities
#243
Author: Arne Vajhøj
Date: Mon, 23 Nov 2026 23:23
24 lines
1627 bytes
On 11/23/2026 5:46 PM, Lawrence D’Oliveiro wrote:
> On Mon, 23 Nov 2026 16:38:33 -0500, Arne Vajhøj wrote:
>> That:
>>
>> IF e1 AND e2 THEN
>>       ...
>> END IF
>>
>> would be more readable as:
>>
>> IF e1 THEN
>>       IF e2 THEN
>>           ...
>>       END IF
>> END IF
> 
> Ada had “and then” and “or else” to explicitly specify short-circuit
> evaluation. And the Algol 68 revival is proposing something similar
> <https://algol68-lang.org/>.

And so does VMS Pascal. Just with underscore instead of space.

Arne
Re: More PHP vulnerabilities
#244
Author: Dan Cross
Date: Tue, 24 Nov 2026 00:37
93 lines
4812 bytes
In article <11e24vp$265v0$1@dont-email.me>,
Simon Clubley  <clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:
>On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>>>>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false,
>>>>> stream_context_create($sslctxopts)) . "\n";
>>>>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>
>>>>> $ php another.php
>>>>> Port = 80
>>>>> Port = 443
>>>>> Port = 80
>>>>> Port = 80
>>>> And for the curious - before fix:
>>>>
>>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>>
>>> I really hope that line was always compiled by a short-circuiting
>>> compiler and that line always successfully triggered short-circuiting...
>>>
>>> Don't be surprised if everyone is now looking for similar constructs
>>> that rely on short-circuiting to be safe.
>> Doesn't C require/mandate short circuiting in cases like this??
>>
>
>As Dan has pointed out, yes. However, I absolutely hate that style of
>coding (and the use of short circuiting in general) - it is way too fragile.
>
>It depends on the compiler behaving as expected and it depends on someone
>not making some edit change that happens to have the unexpected side-effect
>of disabling any working short circuiting.

I'm going to have to push back on this.  Short-circuiting of
boolean operators, in C, is a defined part _of the language_ and
is specified by an international standard.  If a compiler is
miscompiling them, then that's a compiler bug or a language that
is not C.

>Seriously. Please consider not using short circuiting and instead writing
>your code so it works regardless of whether your compiler short-circuits
>or not. (Or it suddenly decides to stop short-circuiting one day).

This begs the question: what other parts of the language should
we not use?

>Oh, and before you all start mocking me, please read this:
>
>https://www.redhat.com/en/blog/security-flaws-caused-compiler-optimizations

Apples and oranges, I'm afraid; that post concerns optimizations
in the face of _undefined behavior_, which is a concept that is
specified in the C standard.  But short-circuiting is
well-defined.

>Even Linux has been caught out in the past by compilers not behaving
>as expected.

Linux is full of bugs, and that's exactly what this is.  The
compiler is right; Linux was wrong.

Here's the TAP/TUN example from that post:

1?   static unsigned int tun_chr_poll(struct file *file, poll_table * wait)
2?   {
3?       struct tun_file *tfile = file->private_data;
4?       struct tun_struct *tun = __tun_get(tfile);
5?       struct sock *sk = tun->sk;
6?       unsigned int mask = 0;
7?       if (!tun)
8?           return POLLERR;

The issue here is that dereferncing a NULL pointer is undefined
behavior, which is behavior for which the C standard imposes
abolutely _no_ requirements.  Thus, a compiler is free to assume
that it does not exist/does not occur; in this case, on line 5,
we dereference `tun` (to get its `sk` member).  But since
deref'ing a NULL pointer is UB, the compiler is free to assume
that it doesn't happen; then, on line 7, the compiler elides the
conditional (and return) since it "knows" that `tun` cannot be
nil, since it was dereferenced on line 5.

But this is _qualitatively different_ than relying on
short-circuiting for `&&` and `||`, which (again) is explicitly
defined by the language.

	- Dan C.
Re: More PHP vulnerabilities
#245
Author: Simon Clubley
Date: Tue, 24 Nov 2026 21:08
60 lines
3860 bytes
On 2026-11-23, Dan Cross <cross@spitfire.i.gajendra.net> wrote:
> In article <11e24vp$265v0$1@dont-email.me>,
> Simon Clubley  <clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:
>>
>>As Dan has pointed out, yes. However, I absolutely hate that style of
>>coding (and the use of short circuiting in general) - it is way too fragile.
>>
>>It depends on the compiler behaving as expected and it depends on someone
>>not making some edit change that happens to have the unexpected side-effect
>>of disabling any working short circuiting.
>
> I'm going to have to push back on this.  Short-circuiting of
> boolean operators, in C, is a defined part _of the language_ and
> is specified by an international standard.  If a compiler is
> miscompiling them, then that's a compiler bug or a language that
> is not C.
>
>>Seriously. Please consider not using short circuiting and instead writing
>>your code so it works regardless of whether your compiler short-circuits
>>or not. (Or it suddenly decides to stop short-circuiting one day).
>
> This begs the question: what other parts of the language should
> we not use?
>

In C, I would like to see people stop using library functions that have
no way of doing bounded buffer copies (strcpy() and friends for example).
I would say that is a common sense thing to ask for, but after some recent
CVEs it would appear common sense is not all that common.

Here's one I just found with a search:

https://www.tenable.com/cve/CVE-2026-80671

In C++, I would like to see people stop using unchecked bounds access
(ie: []) to access containers and start using checked access (ie: at())
always instead. It's insane that [] wasn't the checked option so you got
safer code by default.

BTW, I know some environments now allow [] to become checked. It would
be nice to see that left enabled in production code, especially in
today's environment.

Of course, what I would _really_ like is to see safer languages used in
our critical infrastructure. Said languages should also use readable
syntax to make it easier to learn (Ada is far better than Rust here
for example).

Another minor annoyance of mine. When you write code, you are modelling
a real-world problem. I hate that people sometimes run to using signed
integers by default when most of the time, unsigned integers are a more
accurate match. That's something that's more language-neutral however,
except when dealing with languages that have unexpected side effects with
mixed signed/unsigned expressions. :-)

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
Re: More PHP vulnerabilities
#246
Author: Arne Vajhøj
Date: Tue, 24 Nov 2026 23:39
39 lines
2665 bytes
On 11/24/2026 4:08 PM, Simon Clubley wrote:
> In C, I would like to see people stop using library functions that have
> no way of doing bounded buffer copies (strcpy() and friends for example).
> I would say that is a common sense thing to ask for, but after some recent
> CVEs it would appear common sense is not all that common.

It is going that way.

strlxxx/strxxx_s is taking over from strxxx and strnxxx.

Just too bad that *nix and MS went different ways.

C standard need to catch up.

> In C++, I would like to see people stop using unchecked bounds access
> (ie: []) to access containers and start using checked access (ie: at())
> always instead. It's insane that [] wasn't the checked option so you got
> safer code by default.
> 
> BTW, I know some environments now allow [] to become checked. It would
> be nice to see that left enabled in production code, especially in
> today's environment.

+1

> Another minor annoyance of mine. When you write code, you are modelling
> a real-world problem. I hate that people sometimes run to using signed
> integers by default when most of the time, unsigned integers are a more
> accurate match.

Neither −2147483648..2147483647 nor 0..4294967295 are likely
to map to anything business relevant.

1..10
0..999
etc.

Arne
Re: More PHP vulnerabilities
#247
Author: Dan Cross
Date: Wed, 25 Nov 2026 00:25
86 lines
4680 bytes
In article <11e4ubq$36gi8$1@dont-email.me>,
Simon Clubley  <clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:
>On 2026-11-23, Dan Cross <cross@spitfire.i.gajendra.net> wrote:
>> In article <11e24vp$265v0$1@dont-email.me>,
>> Simon Clubley  <clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:
>>>
>>>As Dan has pointed out, yes. However, I absolutely hate that style of
>>>coding (and the use of short circuiting in general) - it is way too fragile.
>>>
>>>It depends on the compiler behaving as expected and it depends on someone
>>>not making some edit change that happens to have the unexpected side-effect
>>>of disabling any working short circuiting.
>>
>> I'm going to have to push back on this.  Short-circuiting of
>> boolean operators, in C, is a defined part _of the language_ and
>> is specified by an international standard.  If a compiler is
>> miscompiling them, then that's a compiler bug or a language that
>> is not C.
>>
>>>Seriously. Please consider not using short circuiting and instead writing
>>>your code so it works regardless of whether your compiler short-circuits
>>>or not. (Or it suddenly decides to stop short-circuiting one day).
>>
>> This begs the question: what other parts of the language should
>> we not use?
>
>In C, I would like to see people stop using library functions that have
>no way of doing bounded buffer copies (strcpy() and friends for example).

Ok, but those are _library functions_.  Short-circuiting of
operators is a defined part _of the language_, not of a library.

The short circuiting behavior is mandated; it does not depend on
a compiler's whims or optimization levels.  If it is not there,
the compiler is broken: period.

>I would say that is a common sense thing to ask for, but after some recent
>CVEs it would appear common sense is not all that common.
>
>Here's one I just found with a search:
>
>https://www.tenable.com/cve/CVE-2026-80671
>
>In C++, I would like to see people stop using unchecked bounds access
>(ie: []) to access containers and start using checked access (ie: at())
>always instead. It's insane that [] wasn't the checked option so you got
>safer code by default.
>
>BTW, I know some environments now allow [] to become checked. It would
>be nice to see that left enabled in production code, especially in
>today's environment.

I wasn't asking about C++, which is not the same language as C,
but this is the same fundamental thing.

>Of course, what I would _really_ like is to see safer languages used in
>our critical infrastructure. Said languages should also use readable
>syntax to make it easier to learn (Ada is far better than Rust here
>for example).

I agree that programmers should default to safe languages.
Bluntly, very few people are qualified to program in systems
languages.

But I disagree that Ada is more readable than Rust, and I know
other good judges who agree with me on that.  Ada's syntax is
overly verbose for no good reason; it gets in your way, which is
an impediment to understanding.

Further, I find its semantics wanting; we discussed the `'Valid`
attribute here a while back, and I showed that it was both
weaker than and less general than the `Result<T, E>` and
`Option<T>` monads expressible with Rust's ADTs (and those of
other languages).

>Another minor annoyance of mine. When you write code, you are modelling
>a real-world problem. I hate that people sometimes run to using signed
>integers by default when most of the time, unsigned integers are a more
>accurate match. That's something that's more language-neutral however,
>except when dealing with languages that have unexpected side effects with
>mixed signed/unsigned expressions. :-)

This is agree with.

	- Dan C.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads