Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#18 possible infinite loop in linemode code

closed-fixed
None
5
2001-06-25
2001-06-25
Rolf Braun
No

Running diff between BetterTelnet 2.0fc1 and MacSSH
2.1b9 on Linemode.c, I get a bunch of output including
the following. Please look closely at the kbwrite-based
replacement for the tab insertion; I do not believe you
are decrementing numSpaces anywhere in the loop, and if
it ever gets invoked it will run infinitely. Fix: add
numSpaces--; to the body of the while loop below the
kbwrite() call.

That having been said, I hope this code works at all --
it's not such a common situation and I'm not sure it
ever got thoroughly tested in BetterTelnet... but it
looks good otherwise.

thanks,
rolf

@@ -151,19 +139,9 @@
if ((tw->lmodeBits & L_SOFT_TAB)&&(ascii ==
0x09)) // SOFT_TAB mode active; expand tab into spaces
{
short numSpaces =
VSIgetNextTabDistance();
- while (numSpaces > 0)
- {
- while ((numSpaces >
0)&&(tw->kblen < (MAXKB -1)))
- {
- tw->kbbuf[tw->kblen++]
= 0x20; //space
- numSpaces--;
- }
- if (tw->kblen == (MAXKB -1))
- {
- netpush(tw->port);
- netwrite( tw->port,
tw->kbbuf, tw->kblen); /* if full send buffer */
- tw->kblen=0;
- }
+ unsigned char spacechar = ' ';
+ while (numSpaces > 0) {
+ kbwrite(tw, &spacechar, 1);
}
if (tw->echo)
parse(tw, &ascii, 1);

Discussion

  • Rolf Braun
    Rolf Braun
    2001-06-25

    Logged In: YES
    user_id=253224

    I should note: this is not a diff to apply to MacSSH 2.1b9,
    this shows where this code probably broke between
    BetterTelnet 2.0fc1 and MacSSH 2.1b9.

     
  • Logged In: YES
    user_id=158181

    my mistake.
    reverted using the BetterTelnet 2.0fc1 code.

     
    • assigned_to: nobody --> chombier
    • status: open --> closed-fixed