]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 566: fix potential loop in protocol flow control
authorLee Howard <faxguy@howardsilvan.com>
Wed, 11 May 2005 17:35:09 +0000 (17:35 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Wed, 11 May 2005 17:35:09 +0000 (17:35 +0000)
CHANGES
faxd/Class1Recv.c++

diff --git a/CHANGES b/CHANGES
index 67c13563962c54b1f4f41416c1d984c6aab5235b..475fd2542f243211bf0565dd064dc3c29654fb42 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 
 Changelog for HylaFAX
 
+* fix potential looping in Class 1 protocol flow control 
+  mechanisms (11 May 2005)
 * stop sendfax from passing comments to hfaxd due to
   problems with newlines (10 May 2005)
 * fix PAM authentication to set proper UID (9 May 2005)
index 038e308e224781063049ceed44b4966cac23d213..cb754a1184287f5859a409467ee7bf3d1bc2da84 100644 (file)
@@ -705,6 +705,7 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
                            fcpid = fork();
                            char tbuf[1];       // trigger signal
                            tbuf[0] = 0xFF;
+                           time_t rrstart = Sys::now();
                            switch (fcpid) {
                                case -1:        // error
                                    protoTrace("Protocol flow control unavailable due to fork error.");
@@ -733,17 +734,22 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
                                                HDLCFrame rrframe(conf.class1FrameOverhead);
                                                if (gotresponse = recvFrame(rrframe, FCF_RCVR, conf.t2Timer)) {
                                                    tracePPM("RECV recv", rrframe.getFCF());
-                                                   if (params.ec != EC_DISABLE && rrframe.getFCF() != FCF_RR) {
+                                                   if (rrframe.getFCF() == FCF_DCN) {
+                                                       protoTrace("RECV recv DCN");
+                                                       emsg = "COMREC received DCN";
+                                                       gotEOT = true;
+                                                       recvdDCN = true;
+                                                   } else if (params.ec != EC_DISABLE && rrframe.getFCF() != FCF_RR) {
                                                        protoTrace("Ignoring invalid response to RNR.");
                                                    }
                                                    if (!useV34) atCmd(conf.class1SwitchingCmd, AT_OK);
                                                }
-                                           } while (!gotresponse && ++rnrcnt < 2);
+                                           } while (!gotEOT && !recvdDCN && !gotresponse && ++rnrcnt < 2 && Sys::now()-rrstart < 60);
                                            if (!gotresponse) emsg = "No response to RNR repeated 3 times.";
                                        } else {                // parent finished TIFFWriteDirectory
                                            tbuf[0] = 0;
                                        }
-                                   } while (tbuf[0] != 0);
+                                   } while (!gotEOT && !recvdDCN && tbuf[0] != 0 && Sys::now()-rrstart < 60);
                                    Sys::read(fcfd[0], NULL, 1);
                                    exit(0);
                                default:        // parent
@@ -1557,6 +1563,7 @@ Class1Modem::recvPageECMData(TIFF* tif, const Class2Params& params, fxStr& emsg)
            fcpid = fork();
            char tbuf[1];       // trigger signal
            tbuf[0] = 0xFF;
+           time_t rrstart = Sys::now();
            switch (fcpid) {
                case -1:        // error
                    protoTrace("Protocol flow control unavailable due to fork error.");
@@ -1586,14 +1593,19 @@ Class1Modem::recvPageECMData(TIFF* tif, const Class2Params& params, fxStr& emsg)
                                HDLCFrame rrframe(conf.class1FrameOverhead);
                                if (gotresponse = recvFrame(rrframe, FCF_RCVR, conf.t2Timer)) {
                                    tracePPM("RECV recv", rrframe.getFCF());
-                                   if (params.ec != EC_DISABLE && rrframe.getFCF() != FCF_RR) {
+                                   if (rrframe.getFCF() == FCF_DCN) {
+                                       protoTrace("RECV recv DCN");
+                                       emsg = "COMREC received DCN";
+                                       gotEOT = true;
+                                       recvdDCN = true;
+                                   } else if (params.ec != EC_DISABLE && rrframe.getFCF() != FCF_RR) {
                                        protoTrace("Ignoring invalid response to RNR.");
                                    }
                                }
-                           } while (!gotresponse && ++rnrcnt < 2);
+                           } while (!recvdDCN && !gotEOT && !gotresponse && ++rnrcnt < 2 && Sys::now()-rrstart < 60);
                            if (!gotresponse) emsg = "No response to RNR repeated 3 times.";
                        } else tbuf[0] = 0;     // parent finished writeECMData
-                   } while (tbuf[0] != 0);
+                   } while (!gotEOT && !recvdDCN && tbuf[0] != 0 && Sys::now()-rrstart < 60);
                    Sys::read(fcfd[0], NULL, 1);
                    exit(0);
                default:        // parent