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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC