Quantcast

When running exec('rsync') with PHP, getting Warning: Error while sending QUERY packet.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

When running exec('rsync') with PHP, getting Warning: Error while sending QUERY packet.

Björn Tantau
Sorry for the missing cygcheck.out, the Spamfilter wouldn't let me pass. Every package is up to date.
rsync 3.1.2
php 7.0.19
mysql 10.1.19-MariaDB

Hi,

I encountered a rather strange PHP bug I could only reproduce in cygwin
(32 Bit and 64 Bit).
If you have a working MySQL-Connection and then run exec('rsync') the
next Query produces the Warning:
PHP Warning:  Error while sending QUERY packet. PID=15036 in
/home/limora/test.php on line 5

See the attached test.php. It should output:
object(PDOStatement)#2 (1) {
   ["queryString"]=>
   string(16) "SELECT * FROM db"
}
object(PDOStatement)#2 (1) {
   ["queryString"]=>
   string(16) "SELECT * FROM db"
}

but it does output:
object(PDOStatement)#2 (1) {
   ["queryString"]=>
   string(16) "SELECT * FROM db"
}
PHP Warning:  Error while sending QUERY packet. PID=15036 in
/home/limora/test.php on line 5
bool(false)

So far I could reproduce this with the MariaDB from cygwin as well as
xampp, so I guess it's not a MySQL problem. I was only able to reproduce
this with rsync so far and  no other cli program.

I'm completely stumped as to what could be causing this.

Cheers,
Björn

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

test.php (238 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: When running exec('rsync') with PHP, getting Warning: Error while sending QUERY packet.

Brian Inglis
On 2017-05-17 07:39, Björn Tantau wrote:

> I encountered a rather strange PHP bug I could only reproduce in
> cygwin (32 Bit and 64 Bit).
> If you have a working MySQL-Connection and then run exec('rsync') the
> next Query produces the Warning:
> PHP Warning:  Error while sending QUERY packet. PID=15036 in
> /home/limora/test.php on line 5
> test.php:
> <?php
> $pdo = new PDO('mysql:host=127.0.0.1;dbname=mysql', 'root');
> var_dump($pdo->query('SELECT * FROM db'));
> exec('rsync');
> var_dump($pdo->query('SELECT * FROM db'));
> It should output:
> object(PDOStatement)#2 (1) {
>    ["queryString"]=>
>    string(16) "SELECT * FROM db"
> }
> object(PDOStatement)#2 (1) {
>    ["queryString"]=>
>    string(16) "SELECT * FROM db"
> }
> but it does output:
> object(PDOStatement)#2 (1) {
>    ["queryString"]=>
>    string(16) "SELECT * FROM db"
> }
> PHP Warning:  Error while sending QUERY packet. PID=15036 in
> /home/limora/test.php on line 5
> bool(false)
> So far I could reproduce this with the MariaDB from cygwin as well as
> xampp, so I guess it's not a MySQL problem. I was only able to
> reproduce this with rsync so far and  no other cli program.

Try running some other program which fails, like /bin/false, or with
options or args that cause failure, like "/bin/cat /var/empty/*".

> I'm completely stumped as to what could be causing this.

Async reporting by PHP of error 1 generated by running rsync with no
args.
It should be a PHP bug if it does not report any command error.

Try typing "rsync" at a command line and you get the same.
Don't run rsync with no args: don't run commands from web pages;
don't exec commands, without explicit protected executable paths,
whose arguments have been sanitized, or can sanitize its own,
from web pages.

Just look at e.g. the metasploit site for easy steps from PHP to
a remote controlled bot command and control server, with a nice
PHP web front end. "Be careful out there."

--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: When running exec('rsync') with PHP, getting Warning: Error while sending QUERY packet.

Andrey Repin
In reply to this post by Björn Tantau
Greetings, Björn Tantau!

> Sorry for the missing cygcheck.out, the Spamfilter wouldn't let me pass.
> Every package is up to date.
> rsync 3.1.2
> php 7.0.19
> mysql 10.1.19-MariaDB

> Hi,

> I encountered a rather strange PHP bug I could only reproduce in cygwin
> (32 Bit and 64 Bit).
> If you have a working MySQL-Connection and then run exec('rsync')

exec()'ing anything from PHP, especially from PHP running on a webserver is a
very, very, very bad idea.

> the next Query produces the Warning:
> PHP Warning:  Error while sending QUERY packet. PID=15036 in
> /home/limora/test.php on line 5

Show the

phpinfo(~(2+16+32+64));

please...

> So far I could reproduce this with the MariaDB from cygwin as well as
> xampp, so I guess it's not a MySQL problem. I was only able to reproduce
> this with rsync so far and  no other cli program.

> I'm completely stumped as to what could be causing this.

I could guess some possibilities, but I'd like to see settings first.


--
With best regards,
Andrey Repin
Thursday, May 18, 2017 15:23:00

Sorry for my terrible english...
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: When running exec('rsync') with PHP, getting Warning: Error while sending QUERY packet.

Björn Tantau
Am 2017-05-18 14:30, schrieb Andrey Repin:
>> I encountered a rather strange PHP bug I could only reproduce in
>> cygwin
>> (32 Bit and 64 Bit).
>> If you have a working MySQL-Connection and then run exec('rsync')
>
> exec()'ing anything from PHP, especially from PHP running on a
> webserver is a
> very, very, very bad idea.

I know, I know. This is actually a CLI script. The production server
where this is from is actually not allowed to exec anything.

>> the next Query produces the Warning:
>> PHP Warning:  Error while sending QUERY packet. PID=15036 in
>> /home/limora/test.php on line 5
>
> Show the
>
> phpinfo(~(2+16+32+64));
>
> please...

See the attached phpinfo.txt.


And in reply to Brian Inglis (I had only subscribed to the list from my
work account, but stupid Outlook gets caught in the spam filter):
It also happens with valid rsync calls and it doesn't happen with other
programs that error out.


Regards,
Björn

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

phpinfo.txt (29K) Download Attachment
Loading...