~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to libclamav/autoit.c

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2007-2008 Sourcefire, Inc.
 
2
 *  Copyright (C) 2007-2013 Sourcefire, Inc.
3
3
 *
4
4
 *  Authors: Alberto Wu
5
5
 *
35
35
#include <unistd.h>
36
36
#endif
37
37
 
 
38
#include <openssl/ssl.h>
 
39
#include <openssl/err.h>
 
40
#include "libclamav/crypto.h"
 
41
 
38
42
#include "others.h"
39
43
#include "scanners.h"
40
44
#include "autoit.h"
41
45
#include "fmap.h"
 
46
#include "fpu.h"
42
47
 
 
48
static int fpu_words = FPU_ENDIAN_INITME;
43
49
 
44
50
/* FIXME: use unicode detection and normalization from edwin */
45
51
static unsigned int u2a(uint8_t *dest, unsigned int len) {
402
408
  LAME realted stuff 
403
409
*********************/
404
410
 
405
 
#ifdef FPU_WORDS_BIGENDIAN
406
411
#define ROFL(a,b) (( a << (b % (sizeof(a)<<3) ))  |  (a >> (  (sizeof(a)<<3)  -  (b % (sizeof(a)<<3 )) ) ))
407
412
 
408
413
struct LAME {
416
421
  union {
417
422
    double as_double;
418
423
    struct {
419
 
#if FPU_WORDS_BIGENDIAN == 0
420
 
      uint32_t lo;
421
 
      uint32_t hi;
422
 
#else
423
 
      uint32_t hi;
424
 
      uint32_t lo;
425
 
#endif
 
424
      uint32_t lo;
 
425
      uint32_t hi;
426
426
    } as_uint;
427
427
  } ret;
428
428
 
438
438
/*       return 0.0; */
439
439
/*   } */
440
440
 
441
 
  ret.as_uint.lo = rolled << 0x14;
442
 
  ret.as_uint.hi = 0x3ff00000 | (rolled >> 0xc);
 
441
  if (fpu_words == FPU_ENDIAN_LITTLE) {
 
442
      ret.as_uint.lo = rolled << 0x14;
 
443
      ret.as_uint.hi = 0x3ff00000 | (rolled >> 0xc);
 
444
  } else {
 
445
      ret.as_uint.hi = rolled << 0x14;
 
446
      ret.as_uint.lo = 0x3ff00000 | (rolled >> 0xc);
 
447
  }
443
448
  return ret.as_double - 1.0;
444
449
}
445
450
 
744
749
            }
745
750
            buf = newout;
746
751
          }
747
 
#if FPU_WORDS_BIGENDIAN == 0
748
 
          snprintf((char *)&buf[UNP.cur_output], 39, "%g ", *(double *)&UNP.outputbuf[UNP.cur_input]);
749
 
#else
750
 
          do {
751
 
            double x;
752
 
            uint8_t *j = (uint8_t *)&x;
753
 
            unsigned int i;
754
 
 
755
 
            for(i=0; i<8; i++)
756
 
              j[7-i]=UNP.outputbuf[UNP.cur_input+i];
757
 
            snprintf((char *)&buf[UNP.cur_output], 39, "%g ", x); /* FIXME: check */
758
 
          } while(0);
759
 
#endif
 
752
          if (fpu_words == FPU_ENDIAN_LITTLE)
 
753
              snprintf((char *)&buf[UNP.cur_output], 39, "%g ", *(double *)&UNP.outputbuf[UNP.cur_input]);
 
754
          else
 
755
              do {
 
756
                  double x;
 
757
                  uint8_t *j = (uint8_t *)&x;
 
758
                  unsigned int i;
 
759
                  
 
760
                  for(i=0; i<8; i++)
 
761
                      j[7-i]=UNP.outputbuf[UNP.cur_input+i];
 
762
                  snprintf((char *)&buf[UNP.cur_output], 39, "%g ", x); /* FIXME: check */
 
763
              } while(0);
760
764
          buf[UNP.cur_output+38]=' ';
761
765
          buf[UNP.cur_output+39]='\0';
762
766
          UNP.cur_output += strlen((char *)&buf[UNP.cur_output]);
918
922
  return ret;
919
923
}
920
924
 
921
 
#endif /* FPU_WORDS_BIGENDIAN */
922
 
 
923
925
/*********************
924
926
   autoit3 wrapper 
925
927
*********************/
950
952
    r = ea05(ctx, version + 1, tmpd);
951
953
    break;
952
954
  case 0x36:
953
 
#ifdef FPU_WORDS_BIGENDIAN
954
 
    r = ea06(ctx, version + 1, tmpd);
955
 
#else
956
 
    cli_dbgmsg("autoit: EA06 support not available\n");
957
 
    r = CL_CLEAN;
958
 
#endif
959
 
    break;
 
955
      if (fpu_words == FPU_ENDIAN_INITME)
 
956
          fpu_words = get_fpu_endian();
 
957
      if (fpu_words == FPU_ENDIAN_UNKNOWN) {
 
958
          cli_dbgmsg("autoit: EA06 support not available"
 
959
                     "(cannot extract ea06 doubles, unknown floating double representation).\n");
 
960
          r = CL_CLEAN;
 
961
      }
 
962
      else
 
963
          r = ea06(ctx, version + 1, tmpd);
 
964
      break;
960
965
  default:
961
966
    /* NOT REACHED */
962
967
    cli_dbgmsg("autoit: unknown method\n");