php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3601 fgets is NOT binary safe.
Submitted: 2000-02-23 23:10 UTC Modified: 2000-10-30 10:51 UTC
From: iredden at redden dot on dot ca Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0 Beta 4 Patch Level 1 OS: Redhat 6.1 Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: iredden at redden dot on dot ca
New email:
PHP Version: OS:

 

 [2000-02-23 23:10 UTC] iredden at redden dot on dot ca
I am using a UDP socket routine.  fgets does not seem to be binary safe and you cant seem to use fread or fwrite which are two commands which are binary safe.

<?php
$maxlen = 1024;
$default_host = "128.143.204.90";
$default_port = "28001";
$connection = fsockopen("udp://".$default_host, $default_port, &$errno, &$errstr, 5);

if(!$connection) {
        echo "$errstr ($errno)<br>\n";
} else {
        $msgsend = "bah";
        fputs($connection, $msgsend);
        $msgrecv = fgets($connection, $maxlen);
}
echo $msgrecv;
fclose($connection);
?> 

goto http://www.clanhosting.net/packet.doc for the packet query and response packet formats to test my demo.  I have played with this for hours and it just doesnt seem to be binary safe.  Am I doing something wrong???

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-03 14:47 UTC] sas at cvs dot php dot net
Suspending this until UDP support exists.
 [2000-09-04 19:46 UTC] sniper@php.net
Just tested that example script and it worked..but that url given
doesn't exist so I couldn't test it further. 

Stas: I believe UDP-support exists now?
At least manual says so..=)

--Jani
 [2000-10-02 19:05 UTC] sniper@php.net
No feedback.
 [2000-10-02 22:09 UTC] sniper@php.net
Reopened. fgets() supports UDP but isn't binary safe.
To Ian: Could you provide a working example case?
That url didn't work..

--Jani
 [2000-10-02 22:09 UTC] sniper@php.net
Reopened. fgets() supports UDP but isn't binary safe.
To Ian: Could you provide a working example case?
That url didn't work..

--Jani
 [2000-10-12 08:05 UTC] sniper@php.net
User feedback:
--------------
http://php4bug.directoryinfo.net/udp.phps
--------------

Only changes to that first example script are:

$maxlen = 2048;
$default_host = "216.250.231.24";



--Jani
 [2000-10-30 10:50 UTC] stas@php.net
I don't get it. How fgets is supposed to be binary-safe??? It's oriented on \n for end-of-input, so it cannot accept arbitrary input anyway. Why not use fread/fwrite?

Please reopen if there are some other issues except not using fread instead of fgets, such as fread that doesn't work with UDP (which works for me).
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC