Hylafax Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

PATCH: hfaxd 4.0pl1 fixes for WHFC "syntax error" bug



Been testing this fix out for a few days, and it seems to work well.  So
here it is.

This patch to hfaxd fixes the occurrence of the "500 '': Syntax error,
expecting command token." error we've been fighting, using Hylafax 4.0pl1
and WHFC 0.x.  This patch is applied by going to your hfaxd directory, and
feeding the following (after "CUT HERE") to the "patch" utility.

After watching the incoming stream from UNIX and NT clients, the problem
seems to localize in the getCmdLine() function of Parser.c++.  While the
command stream from UNIX clients appears continuous and unbroken, the
Windows client stream is sporadic and broken (odd Gates-ian flow control?).
Is broken flow triggers execution of the lines:

    if (c == EOF)
      return (FALSE);

Hfaxd is then executing other code, then resuming the parse.  It
unfortunately is not remembering where it left off with the partial input
line, and is wiping it out.  This patch fixes this.

Hope it works for you too.  Good luck.

Alan Sparks, IS Engineering Support                   <asparks@harris.com>
Harris Network Support Systems, Camarillo CA     (805) 389-2430

=============== CUT HERE =============================

*** HylaFAXServer.h     Sun Oct 26 15:28:00 1997
--- HylaFAXServer.h.orig        Fri Oct 24 12:09:58 1997
***************
*** 263,268 ****
--- 263,269 ----
      fxStr     tokenBody;              // string body of current lexical
token
      char      cbuf[512];              // current input line
      int               cpos;                   // position in cbuf
+     int               cbuflen;                // position in cbuf
      int               ctrlFlags;              // file descriptor flags for
control
      int               recvCC;                 // amount of data remaining
in recvBuf
      int               recvNext;               // next byte for scanner
*** Parser.c++  Fri Oct 24 11:33:09 1997
--- Parser.c++.orig     Fri Oct 24 12:39:07 1997
***************
*** 281,286 ****
--- 281,287 ----
         */
        if (!getCmdLine(cbuf, sizeof (cbuf)))
            break;
+         cbuflen = 0;
        /*
         * Parse the line of input read above.
         */
***************
*** 1505,1511 ****
  fxBool
  HylaFAXServer::getCmdLine(char* s, int n, fxBool waitForInput)
  {
!     char* cp = s;
      cpos = 0;
      while (n > 1) {
        int c = getChar(cp != s || waitForInput);
--- 1506,1512 ----
  fxBool
  HylaFAXServer::getCmdLine(char* s, int n, fxBool waitForInput)
  {
!     char* cp = s + cbuflen;
      cpos = 0;
      while (n > 1) {
        int c = getChar(cp != s || waitForInput);
***************
*** 1541,1556 ****
        if (c == '\n') {
            // convert \r\n -> \n
            if (cp > s && cp[-1] == '\r')
!               cp[-1] = '\n';
            else
!               *cp++ = '\n', n--;
            break;
        }
!       *cp++ = c, n--;
      }
      *cp = '\0';
      if (TRACE(PROTOCOL))
          logDebug("command: %s", s);
      return (TRUE);
  }

--- 1542,1558 ----
        if (c == '\n') {
            // convert \r\n -> \n
            if (cp > s && cp[-1] == '\r')
!               cp[-1] = '\n', --cbuflen;
            else
!               *cp++ = '\n', ++cbuflen, n--;
            break;
        }
!       *cp++ = c, ++cbuflen, n--;
      }
      *cp = '\0';
      if (TRACE(PROTOCOL))
          logDebug("command: %s", s);
+     cbuflen = 0;
      return (TRUE);
  }

=============== CUT HERE =============================



Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services