Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CentralNic
php-epp
Commits
4e7f7c2c
Commit
4e7f7c2c
authored
Sep 12, 2012
by
Gavin Brown
Browse files
Patch from Nigel Kukard <nkukard@lbsd.net> which handles frame headers split over small buffers.
parent
48061715
Changes
1
Show whitespace changes
Inline
Side-by-side
Net/EPP/Protocol.php
View file @
4e7f7c2c
...
...
@@ -38,17 +38,18 @@ class Net_EPP_Protocol {
* @return PEAR_Error|string either an error or a string
*/
static
function
getFrame
(
$socket
)
{
if
(
@
feof
(
$socket
))
return
new
PEAR_Error
(
'connection closed (socket is EOF)'
);
$hdr
=
''
;
while
(
strlen
(
$hdr
)
<
4
)
{
if
(
@
feof
(
$socket
))
return
new
PEAR_Error
(
'Connection closed (socket is EOF)'
);
if
((
$hdrstr
=
@
fread
(
$socket
,
4
-
strlen
(
$hdr
)))
!==
false
)
{
$hdr
.
=
$hdrstr
;
$hdr
=
@
fread
(
$socket
,
4
);
if
(
empty
(
$hdr
)
&&
feof
(
$socket
))
{
return
new
PEAR_Error
(
'connection closed (no header received and socket is EOF)'
);
}
else
{
return
new
PEAR_ERROR
(
'Error reading from socket:'
.
$php_errormsg
);
}
elseif
(
false
===
$hdr
)
{
return
new
PEAR_Error
(
'Error reading from peer: '
.
$php_errormsg
);
}
}
}
else
{
$unpacked
=
unpack
(
'N'
,
$hdr
);
$length
=
$unpacked
[
1
];
if
(
$length
<
5
)
{
...
...
@@ -60,7 +61,7 @@ class Net_EPP_Protocol {
// sometimes the socket can be buffered with a limit below the frame
// length, so we continually read from the socket until we get the full frame:
$frame
=
''
;
while
(
strlen
(
$frame
)
<
$length
)
$frame
.
=
fread
(
$socket
,
(
$length
)
)
;
while
(
strlen
(
$frame
)
<
$length
)
$frame
.
=
fread
(
$socket
,
$length
);
if
(
strlen
(
$frame
)
>
$length
)
{
return
new
PEAR_Error
(
sprintf
(
"Frame length (%d bytes) doesn't match header (%d bytes)"
,
strlen
(
$frame
),
(
$length
)));
...
...
@@ -71,7 +72,6 @@ class Net_EPP_Protocol {
}
}
}
}
/**
* send an EPP frame to the remote peer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment