[cups-devel] [UNKN] STR #4440: Race condition n cupsdReadClient()

Tim Waugh noreply at cups.org
Thu Jun 19 04:18:07 PDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

There was a race condition in cupsdReadClient() that was fixed here:

==>
commit 5f4cc111af2636c524421c29a0cc53f38a7a7374
Author:     mike <mike at 7a7537e8-13f0-0310-91df-b6672ffda945>
AuthorDate: Fri Feb 22 01:39:06 2013 +0000
Commit:     mike <mike at 7a7537e8-13f0-0310-91df-b6672ffda945>
CommitDate: Fri Feb 22 01:39:06 2013 +0000

    Fix several issues with cupsd reading when there is no data ready,
resulting in
    a timeout.


    git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10879
7a7537e8-13f0-0310-91df-b6672ffda945
- ---
 scheduler/client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scheduler/client.c b/scheduler/client.c
index b08ea4e..15b65db 100644
- --- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -2146,7 +2146,9 @@ cupsdReadClient(cupsd_client_t *con)      /* I -
Client to read from */

          if (con->http.state != HTTP_STATE_POST_SEND)
          {
- -            if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
+           if (!httpWait(HTTP(con), 0))
+             return;
+            else if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) <
0)
            {
              if (con->http.error && con->http.error != EPIPE)
                cupsdLogMessage(CUPSD_LOG_DEBUG,
<==

This prevents the race condition in between the IPP request and the file
data.

However, there is another race condition earlier than that: in between the
HTTP headers and the IPP request.

To see this, run 'gdb --args lp /etc/fstab' and set a breakpoint on
http_write_chunk. Running this through to the breakpoint causes the
scheduler to drop the connection with 'IPP read error'.

I've attached the fix: check for data before calling ippRead().

Link: https://www.cups.org/str.php?L4440
Version: 1.7.3
Attachment: https://www.cups.org/strfiles.php/3345/cups-ipp-read-error.patch
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJTosbvAAoJENujp6sI12IjkdAP/2Un3ZDRZPmGE3EzCXcnbwAE
QRalMZ7AhN2cYc4br5k276rDQCV3jGVB4mUqmSNaHmAr6mgvVbJ8wCnx4dvsi9R9
BiVVihFuuK+46H2dimV75NNVbx1EY6aoruoBM3TjurJKFz49AKji+Az/s9xCv8Xr
/Z800W7XzLr4OOmnlrfwKwPgQx1dVOtGwlpTR8cA4BlvcUt/qA3DvotuiQq48u/f
45wrXrmrcc5iUUopRyGvefhPVc8r3JrEZQzJcDf1oU+B5YbD2qKqujVIQUzCnvpZ
fqlruAgWvKuPGDOeDKJhfWCstRnlzs91ix0AVGEuERste3cLoGbHgnx/PZfshBil
ym7KXw6gmmkmpNOmI+xqSETYKPbchVN9ns00ZE2Bt4v1/2H6h84r1+fgE5F84lnm
TE/qSyW+Rs6F1LkDUeUI5TEuEOK1C1FbvcOplAKOxkQaKsTNIUAvlmLlek6r1bm8
Bz8aSFfOG5fsZJ0JhlnNovv0MI/JHla9ljGPgVFWGtHXSnTLQnu2Xyj8/2PFfU4f
n5giycBbDQzu2/2E4dGAjLs8CsoeeZKM6GwY+ThMz9naJc+JXi3r46P14pfSyJwh
lLiBQBYwvHuYyK3KwNt9jcjJeFXstPEVIPMIZuB1W0Pg/RLY3BgLjHZZ86AVmKND
OjH98nc490cBGl+edziP
=schj
-----END PGP SIGNATURE-----




More information about the cups-devel mailing list