Example #1
0
int
BnetSRP3::init(const char* username_, const char* password_, BigInt* salt_)
{
    unsigned int i;
    const char* source;
    char* symbol;

    if (!username_) {
        eventlog(eventlog_level_error, __FUNCTION__, "got NULL username_");
        return -1;
    }

    username_length = std::strlen(username_);
    username = (char*)xmalloc(username_length + 1);
    source = username_;
    symbol = username;
    for (i = 0; i < username_length; i++)
    {
        *(symbol++) = safe_toupper(*(source++));
    }

    if (!((password_ == NULL) ^ (salt_ == NULL))) {
        eventlog(eventlog_level_error, __FUNCTION__, "need to init with EITHER password_ OR salt_");
        return -1;
    }

    if (password_ != NULL) {
        password_length = std::strlen(password_);
        password = (char*)xmalloc(password_length + 1);
        source = password_;
        symbol = password;
        for (i = 0; i < password_length; i++)
        {
            *(symbol++) = safe_toupper(*(source++));
        }
        a = BigInt::random(32) % N;
        s = BigInt::random(32);
    }
    else {
        password = NULL;
        password_length = 0;
        b = BigInt::random(32) % N;
        s = *salt_;
    }

    B = NULL;

    s.getData(raw_salt, 32);

    return 0;
}
Example #2
0
		//static int versioncheck_compare_exeinfo(char const * pattern, char const * match)
		static int versioncheck_compare_exeinfo(t_parsed_exeinfo * pattern, t_parsed_exeinfo * match)
		{
			assert(pattern);
			assert(match);

			if (!strcasecmp(prefs_get_version_exeinfo_match(), "none"))
				return 0;	/* ignore exeinfo */

			if (std::strlen(pattern->exe) != std::strlen(match->exe))
				return 1; /* neq */

			if (std::strcmp(prefs_get_version_exeinfo_match(), "exact") == 0) {
				return strcasecmp(pattern->exe, match->exe);
			}
			else if (std::strcmp(prefs_get_version_exeinfo_match(), "exactcase") == 0) {
				return std::strcmp(pattern->exe, match->exe);
			}
			else if (std::strcmp(prefs_get_version_exeinfo_match(), "wildcard") == 0) {
				unsigned int i;

				for (i = 0; i < std::strlen(pattern->exe); i++)
				if ((pattern->exe[i] != '?') && /* out "don't care" sign */
					(safe_toupper(pattern->exe[i]) != safe_toupper(match->exe[i])))
					return 1; /* neq */
				return 0; /* ok */
			}
			else if (std::strcmp(prefs_get_version_exeinfo_match(), "parse") == 0) {

				if (strcasecmp(pattern->exe, match->exe) != 0)
				{
					eventlog(eventlog_level_trace, __FUNCTION__, "filename differs");
					return 1; /* neq */
				}
				if (pattern->size != match->size)
				{
					eventlog(eventlog_level_trace, __FUNCTION__, "size differs");
					return 1; /* neq */
				}
				if ((pattern->time != -1) && prefs_get_version_exeinfo_maxdiff() && (abs(pattern->time - match->time) > (signed)prefs_get_version_exeinfo_maxdiff()))
				{
					eventlog(eventlog_level_trace, __FUNCTION__, "time differs by %i", abs(pattern->time - match->time));
					return 1;
				}
				return 0; /* ok */
			}
			else {
				eventlog(eventlog_level_error, __FUNCTION__, "unknown version exeinfo match method \"%s\"", prefs_get_version_exeinfo_match());
				return -1; /* neq/fail */
			}
		}
Example #3
0
static void usrdbg_set(char *opts)
{
  int opt = *opts;
  int new_option;

  if (opt == 0)
    usrdbgmask = DBG_PROC | DBG_LINE | DBG_VAR;
  else
  {
    while (opt)
    {
      new_option = 0;
      switch (safe_toupper(opt))
      {
#ifndef TARGET_IS_UNIX
case 'F': new_option = DBG_PROC;   break;
case 'L': new_option = DBG_LINE;   break;
case 'V': new_option = DBG_VAR;    break;
#endif
default:  new_option = DBG_PROC | DBG_LINE | DBG_VAR;
          cc_msg("unknown debugging option -g%c: -g assumed\n", opt);
      }
      usrdbgmask |= new_option;
      opt = *++opts;
    }
  }
}
Example #4
0
static void rtcheck_set(char *opts)
{
  int opt;
  int32 new_rtcheck;

  for (opt = *opts; opt != 0; opt = *++opts) {
      new_rtcheck = 0;
      switch (safe_toupper(opt)) {
          case 'A': new_rtcheck = RTCHECK_ARRAY;     break;
          case 'C': new_rtcheck = RTCHECK_CASE;      break;
          case 'N': new_rtcheck = RTCHECK_NIL;       break;
          case 'R': new_rtcheck = RTCHECK_REFERENCE; break;
          case 'P': new_rtcheck = RTCHECK_ASSERT; break;
          case 'D': new_rtcheck = RTCHECK_DEADCODE;  break;
          default:  cc_msg("unknown option -r%c: ignored\n", opt);
      }
      rtcheck ^= new_rtcheck;
  }
}
Example #5
0
static void disable_warnings(char *opts)
{
  int opt = *opts;
  int32 new_suppress;

  if (opt == 0)
  {
      var_warn_implicit_fns   = 0;
      var_warn_deprecated     = 0;
      feature |= FEATURE_NOWARNINGS;
      suppress |= D_ASSIGNTEST | D_IMPLICITNARROWING | D_IMPLICITVOID |
                  D_PPNOSYSINCLUDECHECK;
  }
  else
  {
    while (opt)
    {
      new_suppress = 0L;
      switch (safe_toupper(opt))
      {
case 'A': new_suppress = D_ASSIGNTEST;          break;
case 'N': new_suppress = D_IMPLICITNARROWING;   break;
case 'P': new_suppress = D_PPNOSYSINCLUDECHECK; break;
case 'V': new_suppress = D_IMPLICITVOID;        break;
case 'D': var_warn_deprecated = 0;              break;
case 'F': var_warn_implicit_fns = 0;            break;

/* Do I really want to put this in the new version ??? Tony 3/1/95 */
#if 0 
#ifdef TARGET_IS_C40
case 'X':
    new_suppress = D_VOIDRETURN;		break;
#endif
#endif /* 0 */

default:  cc_msg("unknown option -w%c: ignored\n", opt);
      }
      suppress |= new_suppress;
      opt = *++opts;
    }
  }
}
Example #6
0
static void set_compile_options(int argc, char *argv[])
{
  int count, files = 0;
  char message[MAX_NAME];

   /* AM: the following code is intended to deal with things like          */
   /* __CLK_TCK (see <time.h>) being different for different targets.      */
   /* It probably needs better amalgamation into Acorn's code for predefs  */
#ifdef TARGET_PREDEFINES
    {   static char *predefs[] = TARGET_PREDEFINES;
        int i;
        for (i=0; i < sizeof(predefs)/sizeof(predefs[0]); i++)
            /* note that the arg may be of the form "name" or "name=toks" */
            /* the "name" for is equivalent to "name=1".                  */
            pp_predefine(predefs[i]);
    }
#endif

  for (count=1;  count < argc;  ++count)
  {   char *current = argv[count];
      if (current[0] == '-' && current[1] != 0)
      {
          switch (safe_toupper(current[1]))
          {
      case 'C': if (ccom_flags & FLG_PREPROCESS)
                    feature |= FEATURE_PPCOMMENT;
                else
                    ccom_flags |= FLG_NO_OBJECT_OUTPUT;
                break;

      case 'D': pp_predefine(current+2);      break;

      case 'E': /* do we wish to fault -Exxx more generally?            */
#ifdef DISABLE_ERRORS
                if (current[2])
                {   disable_errors(current+2);
                    break;
                }
#endif
#ifdef COMPILING_ON_MVS
                if (current[2])
                {   cc_msg(
       "Obsolete use of '%s' to suppress errors -- use '-zu' for PCC mode\n",
                           current);
                    break;
                }
#endif
                ccom_flags = (ccom_flags | FLG_PREPROCESS) & ~FLG_COMPILE;
                break;

      case 'F': feature_set(current+2);       break;

#ifdef TARGET_HAS_DEBUGGER
      case 'G': usrdbg_set(current+2);        break;
#endif

      case 'I': set_include_path(current+2, PE_USER);  break;

      case 'J': ccom_flags &= ~FLG_INSTORE_FILES_IMPLICITLY;
                set_include_path(current+2, PE_SYS);  break;

      case 'K': ccom_flags |= FLG_COUNTS;
                break;

#ifndef NO_LISTING_OUTPUT
      case 'L': ccom_flags |= FLG_LISTING;
                listingfile = current + 2;
                break;
#endif

      case 'M': ccom_flags |= FLG_MAKEFILE;
                if (current[2] == '<' || current[2] == 0)
                {   ccom_flags &= ~(FLG_COMPILE+FLG_NOSYSINCLUDES);
                    if (current[2] == '<') ccom_flags |= FLG_NOSYSINCLUDES;
                }
                else
                    makefile = current+2;
                break;

      case 'O': /*
                 * Hum, really we should never get here because this
                 * this should be done by -zpz1.
                 */
                break;

/* Paranoid define check. Tony 3/1/95 */
#ifdef TARGET_HAS_PROFILE
#error	Old style define TARGET_HAS_PROFILE (replaced by TARGET_HAS_PROFILER)
#endif

#ifdef TARGET_HAS_PROFILER
      case 'P': { int ch = safe_toupper(current[2]);
                  int32 profile = 1L;
                  if (ch == 0)
                    /* do nothing */;
                  else if (ch == 'G' || ch == 'X' && current[3] == 0)
                    profile = 2L;
                  else
                    cc_msg("unknown profile option %s: -p assumed\n",current);
                  var_profile_option = profile;
                }
                break;
#endif /* TARGET_HAS_PROFILER */

      case 'R':
#ifdef PASCAL /*ECN*/
                rtcheck_set(current+2);
#else
                feature &= ~FEATURE_WR_STR_LITS;
#endif
                break;

      case 'S': asmfile = current+2;  /* "" for -S */
#ifdef COMPILING_ON_MVS
                /* pesky cc163 compatibility */
                if (*asmfile == 0 && count+1<argc)
                    asmfile = argv[++count];
#endif
                break;

#ifdef TARGET_IS_XPUTER
      case 'T': /* -tn sets processor type == -tn */
	  	pragma_set(current + 1);
	  	break;
#endif
	  

      case 'U': pp_preundefine(current+2);          break;

      case 'W': disable_warnings(current+2);        break;

#ifdef TARGET_IS_MVS    /* TARGET_USES_CCOM_INTERFACE ??? */
/* The following case provides -Xcsectname for CC 163 compatibility.    */
/* It may be that the CCOM-style interface should stuff ALL unknown     */
/* options to mcdep_config_option()?                                    */
      case 'X': if (!mcdep_config_option(current[1], current+2))
                    cc_msg("unknown option %s: ignored\n", current);
                break;
#endif

      case 'Z': switch(safe_toupper(current[2]))
                {
          case 'B': target_lsbitfirst = !target_lsbytefirst;
                    if (isdigit(current[3]))
                        target_lsbitfirst = (current[3]-'0');
                    break;
#ifdef TARGET_ENDIANNESS_CONFIGURABLE
          case 'E': { int lsbytefirst = current[3] - '0';
                      if (lsbytefirst)
                          config &= ~CONFIG_BIG_ENDIAN;
                      else
                          config |= CONFIG_BIG_ENDIAN;
                      target_lsbitfirst = lsbytefirst;
                    }
                    break;
#endif
          case 'C': feature |= FEATURE_SIGNED_CHAR;
                    break;
          case 'F': feature = (feature | FEATURE_FUSSY) & ~FEATURE_LIMITED_PCC;
                    break;
          case 'I': pre_include(current+3);
                    break;
          case 'J': config |= CONFIG_INDIRECT_SETJMP;  /* related to -fR */
                    break;
          case 'P': pragma_set(current+3);
                    break;
          case 'O': feature |= FEATURE_AOF_AREA_PER_FN;
                    break;
          case 'Q': debug_set(current+3);
                    break;
#ifndef TARGET_IS_HELIOS
          case 'S': system_flavour = current+3;
                    break;
#endif
          case 'U': feature |= pcc_features();
                    break;
#ifdef TARGET_IS_TRAN
	      /*
	       * Addition to remove C++ warnings (for fussy IGM people).
	       * Tony 8/2/95.
	       */
	  case 'W':
	      feature |= FEATURE_NO_CPLUSPLUS_WARNINGS;
	      
	      break;
#endif /* TARGET_IS_TRAN */

#ifdef PASCAL /*ECN*/
          case 'Z': feature |= FEATURE_ISO;
                    break;
#endif
          default:  if (!mcdep_config_option(current[2], current+3))
                        cc_msg("unknown option %s: ignored\n", current);
                    break;
                }
                break;
      default:  cc_msg("unknown option %s: ignored\n", current);
                break;
          }
      }
      else
      {
          switch (++files)
          {
      case 1:   if (strcmp(current, "-") == 0)
                {   /* then just leave as stdin */
#ifdef COMPILING_ON_RISC_OS
#  ifndef OBSOLETE_ARM_NAMES
                    /* Hack round default no-buffering library.         */
                    setvbuf(stdin, NULL, _IOLBF, 256);
#  endif
#endif
                }
                else if (freopen(current,"r",stdin) != NULL)
                {   UnparsedName unparse;
                    char new_dir[MAX_NAME];
                    ccom_flags &= ~FLG_STDIN;
                    sourcefile = current;
                    /*
                     * Add path name of source file to the -I list.
                     */
                    translate_fname(current, &unparse, new_dir);
                    new_dir[unparse.un_pathlen] = '\0';
                    path_hd = mk_path_element(path_hd, PE_USER, new_dir);
/* Make sure path_tl is always the tail, even if file precedes -I    */
                    if (path_hd->link == 0) path_tl = path_hd;
                }
                else
                {
                    sprintf(message, "couldn't read file '%s'", current);
                    driver_abort(message);
                }
                break;
      case 2:   objectfile = current;
                break;
      default:  driver_abort("too many file arguments");
          }
      }
  }
  if (ccom_flags & FLG_STDIN)
  {   path_hd = mk_path_element(path_hd, PE_USER, "");
      if (path_hd->link == 0) path_tl = path_hd;
  }

#ifdef TARGET_HAS_SEPARATE_CODE_DATA_SEGS
  /* On machines like amd29000 code and data buses are separate    */
  /* so that all non-instruction data must go in the data segment. */
#if defined TARGET_IS_C40
  /*
   * Ho Hum
   *
   * The problem is that programs built with the -Zr option, (such as
   * the kernel and device drivers), do not have a static data area.
   * This means that strings MUST be placed into the code segment.  BUT
   * on the C40 data pointers can only address 1/4 of the address map, and
   * so they may not be able to reach the code segment.  (This is especially
   * true when you consider that the C40 has two address buses, and the plan
   * is to have data on one bus and code on the other).  HENCE by default we
   * want to disable placing strings in the code segment, but for -Zr programs
   * we have no choice ...
   */
  
  if (suppress_module != 1)
    {
      feature |= FEATURE_WR_STR_LITS;
    }
  else
    {
      feature &= ~FEATURE_WR_STR_LITS;
    }
#else
  feature |= FEATURE_WR_STR_LITS;
#endif /* TARGET_IS_C40 */
#endif /* TARGET_HAS_SEPARATE_CODE_DATA_SEGS */

  if (ccom_flags & FLG_COMPILE)
  {
      /* under the driver.c interface at most one of the following is true */
#ifndef NO_OBJECT_OUTPUT
      if (objectfile[0] != '\0' && !(ccom_flags & FLG_NO_OBJECT_OUTPUT))
      {   objstream = cc_open(objectfile, BINARY_FILE);
# ifdef COMPILING_ON_RISC_OS
          set_time_stamp(objectfile, NO);
# endif
      }
#endif
#ifndef NO_ASSEMBLER_OUTPUT
      if (asmfile[0] != '\0') asmstream = cc_open(asmfile, TEXT_FILE);
#endif
      if (objectfile[0] == '\0' && asmfile[0] == '\0')
      {
          asmstream = stdout;
          feature |= FEATURE_ANNOTATE;   /* simple test use */
      }

#ifndef NO_LISTING_OUTPUT
      if (ccom_flags & FLG_LISTING)
      {
          if (listingfile[0] != '\0')
          {
              listingstream = cc_open(listingfile, TEXT_FILE);
              if (listingstream != stdout)   /* @@@ get rid of this hack */
                  fprintf(listingstream, "     1  ");
          }
          else listingstream = stdout;
          if (ccom_flags & FLG_COUNTS)
          { FILE *map = fopen("counts", "rb");
            if (map == NULL) driver_abort("couldn't read \"counts\" file");
            if (!map_init(map)) driver_abort("malformed \"counts\" file");
          }
      }
#endif
  }

  if (ccom_flags & FLG_MAKEFILE)
  {
      if (makefile[0] == 0)
          makestream = stdout;
      else
      {
          makestream = cc_open(makefile, TEXT_FILE);
      }
      /*
       *  Print out source file and object file for -M option
       */
      fprintf(makestream, DEPEND_FORMAT, objectfile, sourcefile);
  }
}
Example #7
0
static void debug_set(char *opts)
{
  int opt;
  long debugmask = 0L;

  for (opt = *opts;  opt != 0;  opt = *++opts)
  {
    debugmask = 0L;
    switch (safe_toupper(opt))
    {
#ifdef ENABLE_AETREE
case 'A': debugmask = DEBUG_AETREE;    break;
#endif
#ifdef ENABLE_BIND
case 'B': debugmask = DEBUG_BIND;      break;
#endif
#ifdef ENABLE_CSE
case 'C': cse_debugcount++;
          debugmask = DEBUG_CSE;       break;
#endif
#ifdef ENABLE_DATA
case 'D': debugmask = DEBUG_DATA;      break;
#endif
#ifdef ENABLE_FNAMES
case 'F': debugmask = DEBUG_FNAMES;    break;
#endif
#ifdef ENABLE_CG
case 'G': debugmask = DEBUG_CG;        break;
#endif
#ifdef ENABLE_SPILL
case 'H': debugmask = DEBUG_SPILL;     break;
#endif
#ifdef ENABLE_FILES
case 'I': debugmask = DEBUG_FILES;     break;
#endif
#ifdef ENABLE_LOCALCG
case 'K': localcg_debugcount++;
          debugmask = DEBUG_LOCALCG;   break;
#endif
#ifdef ENABLE_LEX
case 'L': debugmask = DEBUG_LEX;       break;
#endif
#ifdef ENABLE_MAPSTORE
case 'M': debugmask = DEBUG_MAPSTORE;  break;
#endif
#ifdef ENABLE_OBJ
case 'O': debugmask = DEBUG_OBJ;       break;
#endif
#ifdef ENABLE_PP
case 'P': debugmask = DEBUG_PP;        break;
#endif
#ifdef ENABLE_Q
case 'Q': debugmask = DEBUG_Q;         break;
#endif
#ifdef ENABLE_REGS
case 'R': debugmask = DEBUG_REGS;      break;
#endif
#ifdef ENABLE_SYN
case 'S': debugmask = DEBUG_SYN;       break;
#endif
#ifdef ENABLE_TYPE
case 'T': debugmask = DEBUG_TYPE;      break;
#endif
#ifdef ENABLE_STORE
case 'U': debugmask = DEBUG_STORE;     break;
#endif
#ifdef ENABLE_2STORE
case 'W': debugmask = DEBUG_2STORE;    break;
#endif
#ifdef ENABLE_X
case 'X': debugmask = DEBUG_X;         break;
#endif
#ifdef ENABLE_LOOP
case 'Y': debugmask = DEBUG_LOOP;      break;
#endif
/*
 * -Qz to modify syserr behaviour is always available
 */
case 'Z': syserr_behaviour++;
#ifndef COMPILING_ON_MSDOS
#ifdef __CC_NORCROFT
          (void) signal(SIGINT, SIG_DFL);     /* permit NorCroft backtrace */
#endif
#endif
          break;
default:  cc_msg("unknown option -zq%c: ignored\n", opt);
    }
    sysdebugmask |= debugmask;
  }
}
Example #8
0
static void feature_set(char *opts)
{
  int opt;
#define UNUSED 0
  static int32 feature_flags[] = {
        /* 'A' */ FEATURE_ANOMALY,
        /* 'B' */ FEATURE_VERBOSE,
        /* 'C' */ FEATURE_LIMITED_PCC,
#ifdef TARGET_IS_C40
        /* 'D' */ FEATURE_OLD_STUBS,
#else
        /* 'D' */ UNUSED,
#endif
        /* 'E' */ FEATURE_6CHARMONOCASE,
        /* 'F' */ 0L-FEATURE_SAVENAME,               /* N.B. -ve */
        /* 'G' */ UNUSED,
        /* 'H' */ FEATURE_PREDECLARE,
        /* 'I' */ FEATURE_USERINCLUDE_LISTING,
        /* 'J' */ FEATURE_SYSINCLUDE_LISTING,
        /* 'K' */ FEATURE_KANDR_INCLUDE,
        /* 'L' */ FEATURE_DONTUSE_LINKREG,
        /* 'M' */ FEATURE_PPNOUSE,
        /* 'N' */ FEATURE_SAVENAME,
        /* 'O' */ FEATURE_WARNOLDFNS,
        /* 'P' */ FEATURE_TELL_PTRINT,
        /* 'Q' */ FEATURE_ALLOWCOUNTEDSTRINGS,
        /* 'R' */ FEATURE_LET_LONGJMP_CORRUPT_REGVARS,
        /* 'S' */ FEATURE_ANNOTATE,
#ifdef TARGET_IS_C40
        /* 'T' */ 0L - FEATURE_WARNOLDFNS,
#else
        /* 'T' */ UNUSED,
#endif
        /* 'U' */ FEATURE_UNEXPANDED_LISTING,
        /* 'V' */ FEATURE_NOUSE,
        /* 'W' */ FEATURE_WR_STR_LITS,
        /* 'X' */ UNUSED,
        /* 'Y' */ UNUSED,
        /* 'Z' */ FEATURE_INLINE_CALL_KILLS_LINKREG
    };
#undef UNUSED

  for (opt = *opts;  opt != 0;  opt = *++opts)
  {   int ch = safe_toupper(opt);
      if (ch >= 'A')
      {   int n = ASCII(ch) - ASCII('A');
          if (n < sizeof(feature_flags)/sizeof(int32))
          {   int32 flag = feature_flags[n];
              if (flag < 0)
                  feature &= ~-flag;
              else if (flag > 0)
                  feature |= flag;
              else
                  goto unknown;
          }
          else if (ch == 'X')
              suppress &= ~D_SUPPRESSED;
          else if (ch == 'Z')
              ccom_flags |= FLG_USE_SYSTEM_PATH;
          else
unknown:      cc_msg("unknown option -f%c: ignored\n", opt);
      }
  }
}