Logically appears to be true that it evaluates to FALSE.  The proof
of the pudding is sometimes in the code.  Internat is from filetypes.c.

~$ cat tst.c
#include <stdio.h>

static char internat[256] = {
    /* TODO: Remember to buy a beer to Joerg Wunsch <[EMAIL PROTECTED]>
*/
    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0,  /* 0x0X */
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,  /* 0x1X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x2X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x3X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x4X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x5X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x6X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,  /* 0x7X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x8X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0x9X */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0xaX */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0xbX */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0xcX */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0xdX */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 0xeX */
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1   /* 0xfX */
};

int main(int argc, char **argv)
{
  char c;
  int i;
  int any;
  any = 0;
  printf("Evaluating !iscntrl(c) && !isprint(c) && !internat[c &
0xff]\n"
         "for c in integer values 0..255\n");
  for (i=255; i >= 0; --i)
  {
    c = i;
    if (!iscntrl(c) && !isprint(c) && !internat[c & 0xff])
    {
      printf("True for int(c) == %d, c == %c\n", c, c);
      any = 1;
    }
  }
  if (any)
    printf("Expression evaluated TRUE for some c\n");
  else
    printf("Expression evaluated FALSE for all c\n");
}

~$ make tst
cc     tst.c   -o tst

~$ tst
Evaluating !iscntrl(c) && !isprint(c) && !internat[c & 0xff]
for c in integer values 0..255
Expression evaluated FALSE for all c

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dale Walsh
Sent: Thursday, March 01, 2007 5:55 AM
To: ClamAV Development
Subject: Re: [Clamav-devel] One problem in filetype.c in clamav0.90

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Feb 27, 2007, at 22:28:38, alex wrote:

> Dears all:
>
> I have read the source code of clamav 0.90 and found a strange code in

> filetype.c.
>
> There is an expressioniIn 233 line of filetype.c :
>
>               if(!iscntrl(buf[i]) && !isprint(buf[i]) && !internat 
> [buf[i] & 0xff])
>
> and this expression would ALWAYS be false.

Good catch, yes I stepped/traced this several times and it always
evaluates as false.

> I want to know if i am wrong ?
>
> Thanks

- -- Dale


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)

iD8DBQFF5tsziD9DTPch4RQRAr0LAJ42/Fa/niHE/J86zWNQrUSOysBf7ACgsD+F
IJrgDNcmCgKc/ZQpBtBSvAU=
=gEiQ
-----END PGP SIGNATURE-----
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net

Reply via email to