[Exim] NULL/filter : reprise

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Hugh Sasse Staff Elec Eng
Date:  
À: EXIM users list
Sujet: [Exim] NULL/filter : reprise
Further to all the discussion about the NULLs in the gibe worm tripping
up the executable content filter:

The patches posted by Philip Hazel before fixed the problem, but I still
had problems. It turned out that this was because the patches didn't
affect the processing in filter test mode (-bf/-bF options).

Philip sent me this patch below, which obsoletes the previous patch,
and this fixes both modes. It is a patch against 3.35 as distributed.

Thanks again for Philip's help and his putting up with a stream of
e-mails from me on the topic!

        Hugh


*** exim-3.35/src/expand.c  Tue Feb 19 10:10:43 2002
--- expand.c    Mon Mar 11 21:15:47 2002
***************
*** 572,581 ****
        lseek(deliver_datafile, start_offset, SEEK_SET);
        len = read(deliver_datafile, body, len);
        if (len >= 0) body[len] = 0;
!       while (*body != 0)
          {
!         if (*body == '\n') *body = ' ';
!         body++;
          }
        }
      return (*ss == NULL)? "" : *ss;
--- 572,580 ----
        lseek(deliver_datafile, start_offset, SEEK_SET);
        len = read(deliver_datafile, body, len);
        if (len >= 0) body[len] = 0;
!       while (len > 0)
          {
!         if (body[--len] == '\n' || body[len] == 0) body[len] = ' ';
          }
        }
      return (*ss == NULL)? "" : *ss;


*** exim-3.35/src/filter.c  Tue Feb 19 10:10:43 2002
--- filter.c    Wed Mar 20 11:03:50 2002
***************
*** 2566,2577 ****
  BOOL
  filter_runtest(int fd, BOOL is_system, BOOL dot_ended)
  {
! int rc, body_len, action, header_size;
  register int ch;
  BOOL yield, delivered;
  struct stat statbuf;
  address_item *generated = NULL;
! char *body, *error, *filebuf, *s;


/* Read the filter file into store as will be done by the director
in a real case. */
--- 2566,2577 ----
BOOL
filter_runtest(int fd, BOOL is_system, BOOL dot_ended)
{
! int rc, body_len, body_end_len, action, header_size;
register int ch;
BOOL yield, delivered;
struct stat statbuf;
address_item *generated = NULL;
! char *error, *filebuf, *s;

/* Read the filter file into store as will be done by the director
in a real case. */
***************
*** 2653,2659 ****
function as efficient as possible. Handling message_body_end is somewhat more
tedious. Pile it all into a circular buffer and sort out at the end. */

! message_body = body = store_malloc(message_body_visible + 1);
message_body_end = store_malloc(message_body_visible + 1);
s = message_body_end;
body_len = 0;
--- 2653,2659 ----
function as efficient as possible. Handling message_body_end is somewhat more
tedious. Pile it all into a circular buffer and sort out at the end. */

! message_body = store_malloc(message_body_visible + 1);
  message_body_end = store_malloc(message_body_visible + 1);
  s = message_body_end;
  body_len = 0;
***************
*** 2729,2752 ****
      memcpy(temp, message_body_end, below);
      memmove(message_body_end, s+1, above);
      memcpy(message_body_end + above, temp, below);
!     message_body_end[message_body_visible] = 0;
      }
    }
- else *s = 0;


! /* Convert newlines in the body variables to spaces */

! while (*body != 0)
    {
!   if (*body == '\n') *body = ' ';
!   body++;
    }


! body = message_body_end;
! while (*body != 0)
    {
!   if (*body == '\n') *body = ' ';
!   body++;
    }


  /* Now pass the filter file to the function that interprets it. Because
--- 2729,2754 ----
      memcpy(temp, message_body_end, below);
      memmove(message_body_end, s+1, above);
      memcpy(message_body_end + above, temp, below);
!     s = message_body_end + message_body_visible;
      }
    }


! *s = 0;
! body_end_len = s - message_body_end;

! /* Convert newlines and nulls in the body variables to spaces */
!
! while (body_len > 0)
    {
!   if (message_body[--body_len] == '\n' || message_body[body_len] == 0)
!     message_body[body_len] = ' ';
    }


! while (body_end_len > 0)
    {
!   if (message_body_end[--body_end_len] == '\n' ||
!       message_body_end[body_end_len] == 0)
!     message_body_end[body_end_len] = ' ';
    }


/* Now pass the filter file to the function that interprets it. Because