Changeset 89 for trunk/src


Ignore:
Timestamp:
Jan 29, 2007, 9:40:44 PM (18 years ago)
Author:
rainer
Message:

Fix for ticket #49 (stealth mode broken). Regression test added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_unix.c

    r86 r89  
    43234323
    43244324
    4325 int hideout_hex_block(SL_TICKET fd, unsigned char * str, int len);
     4325int hideout_hex_block(SL_TICKET fd, unsigned char * str, int len,
     4326                      unsigned long * bytes_read);
    43264327unsigned long first_hex_block(SL_TICKET fd, unsigned long * max);
    43274328
     
    43314332int sh_unix_getline_stealth (SL_TICKET fd, char * str, int len)
    43324333{
    4333   int                  add_off, llen;
    4334   static unsigned long off_data = 0;
    4335   static unsigned long max_data = 0;
     4334  int                  add_off = 0, llen;
     4335  static unsigned long off_data   = 0;
     4336  static unsigned long max_data   = 0;
     4337  static unsigned long bytes_read = 0;
    43364338  static int           stealth_init = BAD;
    43374339
     
    43584360  /* --- Seek to proper position. ---
    43594361   */
    4360   if (off_data >= max_data)
     4362  if (bytes_read >= max_data || add_off < 0)
    43614363    {
    43624364      dlog(1, FIL__, __LINE__,
     
    43704372  /* --- Read one line. ---
    43714373   */
    4372   add_off   = hideout_hex_block(fd, (unsigned char *) str, len);
     4374  add_off   = hideout_hex_block(fd, (unsigned char *) str, len, &bytes_read);
    43734375  off_data += add_off;
    43744376
     
    43774379}
    43784380
    4379 int hideout_hex_block(SL_TICKET fd, unsigned char * str, int len)
     4381int hideout_hex_block(SL_TICKET fd, unsigned char * str, int len,
     4382                      unsigned long * bytes_read)
    43804383{
    43814384
     
    43864389  unsigned long here   = 0;
    43874390  unsigned long retval = 0;
     4391  unsigned long bread  = 0;
    43884392
    43894393  SL_ENTER(_("hideout_hex_block"));
     
    44104414                  num = sl_read (fd, &c, 1);
    44114415                } while (num == 0 && errno == EINTR);
    4412                 if (num == 0)
     4416                if (num > 0)
     4417                  ++here;
     4418                else if (num == 0)
    44134419                  SL_RETURN((0), _("hideout_hex_block"));
    4414                 ++here;
     4420                else
     4421                  SL_RETURN((-1), _("hideout_hex_block"));
    44154422              } while (c == '\n' || c == '\t' || c == '\r' ||
    44164423                       c == ' ');
     
    44264433            str[i] &= ~mask[j];
    44274434
     4435          bread += 1;
    44284436        }
    44294437      if (str[i] == '\n') break;
     
    44364444    str[i+1] = '\0'; /* keep newline and terminate */
    44374445  retval += here;
     4446  *bytes_read += (bread/8);
    44384447
    44394448  SL_RETURN(retval, _("hideout_hex_block"));
Note: See TracChangeset for help on using the changeset viewer.