Subversion Repositories SvarDOS

Rev

Rev 983 | Rev 989 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 983 Rev 987
Line 868... Line 868...
868
      }
868
      }
869
      /* skip the @ prefix if present, it is no longer useful */
869
      /* skip the @ prefix if present, it is no longer useful */
870
      if (cmdline[0] == '@') cmdline++;
870
      if (cmdline[0] == '@') cmdline++;
871
    } else {
871
    } else {
872
      unsigned char far *rmod_inputbuf = MK_FP(rmod->rmodseg, RMOD_OFFSET_INPUTBUF);
872
      unsigned char far *rmod_inputbuf = MK_FP(rmod->rmodseg, RMOD_OFFSET_INPUTBUF);
873
      unsigned short far *rmod_stacksig = MK_FP(rmod->rmodseg, RMOD_OFFSET_STACKSIG);
-
 
874
      /* invalidate input history if it appears to be damaged (could occur
873
      /* invalidate input history if it appears to be damaged (could occur
875
       * because of a stack overflow, for example if some stack-hungry TSR is
874
       * because of a stack overflow, for example if some stack-hungry TSR is
876
       * being used) */
875
       * being used) */
-
 
876
      if ((rmod_inputbuf[0] != 128) || (rmod_inputbuf[rmod_inputbuf[1] + 2] != '\r') || (rmod_inputbuf[rmod_inputbuf[1] + 3] != 0xCA) || (rmod_inputbuf[rmod_inputbuf[1] + 4] != 0xFE)) {
877
      if (*rmod_stacksig != 0xCAFE) {
877
        rmod_inputbuf[0] = 128;  /* max allowed input length */
878
        *rmod_stacksig = 0xCAFE;
878
        rmod_inputbuf[1] = 0;    /* string len stored in buffer */
879
        rmod_inputbuf[0] = 128; /* max allowed input length */
879
        rmod_inputbuf[2] = '\r'; /* string terminator */
880
        rmod_inputbuf[1] = 0;
880
        rmod_inputbuf[3] = 0xCA; /* trailing signature */
881
        rmod_inputbuf[2] = '\r';
881
        rmod_inputbuf[4] = 0xFE; /* trailing signature */
882
        /* printf("STACK OVERFLOW DETECTED: HISTORY FLUSHED\r\n"); */
882
        outputnl("SvarCOM: stack overflow detected, command history flushed (this is not a bug)");
883
      }
883
      }
884
      /* interactive mode: display prompt (if echo enabled) and wait for user
884
      /* interactive mode: display prompt (if echo enabled) and wait for user
885
       * command line */
885
       * command line */
886
      if (rmod->flags & FLAG_ECHOFLAG) build_and_display_prompt(BUFFER, *rmod_envseg);
886
      if (rmod->flags & FLAG_ECHOFLAG) build_and_display_prompt(BUFFER, *rmod_envseg);
887
      /* collect user input */
887
      /* collect user input */
888
      cmdline_getinput(rmod->rmodseg, RMOD_OFFSET_INPUTBUF);
888
      cmdline_getinput(rmod->rmodseg, RMOD_OFFSET_INPUTBUF);
-
 
889
      /* append stack-overflow detection signature to the end of the input buffer */
-
 
890
      rmod_inputbuf[rmod_inputbuf[1] + 3] = 0xCA; /* trailing signature */
-
 
891
      rmod_inputbuf[rmod_inputbuf[1] + 4] = 0xFE; /* trailing signature */
889
      /* copy it to local cmdline */
892
      /* copy it to local cmdline */
890
      if (rmod_inputbuf[1] != 0) _fmemcpy(cmdline, rmod_inputbuf + 2, rmod_inputbuf[1]);
893
      if (rmod_inputbuf[1] != 0) _fmemcpy(cmdline, rmod_inputbuf + 2, rmod_inputbuf[1]);
891
      cmdline[rmod_inputbuf[1]] = 0; /* zero-terminate local buff (original is '\r'-terminated) */
894
      cmdline[rmod_inputbuf[1]] = 0; /* zero-terminate local buff (original is '\r'-terminated) */
892
    }
895
    }
893
 
896