Пример #1
0
static void set_key(char *key, int index)
{
#ifndef MD5_SSE_PARA
	MD5_std_set_key(key, index);
#endif

	strnfcpy(saved_key[index], key, PLAINTEXT_LENGTH);
}
Пример #2
0
static int single_add_key(struct db_salt *salt, char *key, int is_from_guesses)
{
    struct db_keys *keys = salt->keys;
    int index, new_hash, reuse_hash;
    struct db_keys_hash_entry *entry;

    /* Check if this is a known duplicate, and reject it if so */
    if ((index = keys->hash->hash[new_hash = single_key_hash(key)]) >= 0)
        do {
            entry = &keys->hash->list[index];
            if (!strncmp(key, &keys->buffer[entry->offset], length))
                return 0;
        } while ((index = entry->next) >= 0);

    /* Update the hash table removing the list entry we're about to reuse */
    index = keys->hash->hash[reuse_hash = single_key_hash(keys->ptr)];
    if (index == keys->count)
        keys->hash->hash[reuse_hash] = keys->hash->list[index].next;
    else if (index >= 0) {
        entry = &keys->hash->list[index];
        while ((index = entry->next) >= 0) {
            if (index == keys->count) {
                entry->next = keys->hash->list[index].next;
                break;
            }
            entry = &keys->hash->list[index];
        }
    }

    /* Add the new entry */
    index = keys->hash->hash[new_hash];
    entry = &keys->hash->list[keys->count];
    entry->next = index;
    entry->offset = keys->ptr - keys->buffer;
    keys->hash->hash[new_hash] = keys->count;

    strnfcpy(keys->ptr, key, length);
    keys->ptr += length;

    keys->count_from_guesses += is_from_guesses;

    if (++(keys->count) >= key_count)
        return single_process_buffer(salt);

    return 0;
}
static void set_key(char *key, int index)
{
	MD5_std_set_key(key, index);

	strnfcpy(saved_key[index], key, PLAINTEXT_LENGTH);
}
Пример #4
0
int rfc1524_expand_filename (char *nametemplate,
			     char *oldfile, 
			     char *newfile,
			     size_t nflen)
{
  int i, j, k, ps;
  char *s;
  short lmatch = 0, rmatch = 0; 
  char left[_POSIX_PATH_MAX];
  char right[_POSIX_PATH_MAX];
  
  newfile[0] = 0;

  /* first, ignore leading path components.
   */
  
  if (nametemplate && (s = strrchr (nametemplate, '/')))
    nametemplate = s + 1;

  if (oldfile && (s = strrchr (oldfile, '/')))
    oldfile = s + 1;
    
  if (!nametemplate)
  {
    if (oldfile)
      strfcpy (newfile, oldfile, nflen);
  }
  else if (!oldfile)
  {
    mutt_expand_fmt (newfile, nflen, nametemplate, "mutt");
  }
  else /* oldfile && nametemplate */
  {

    /* first, compare everything left from the "%s" 
     * (if there is one).
     */
    
    lmatch = 1; ps = 0;
    for(i = 0; nametemplate[i]; i++)
    {
      if(nametemplate[i] == '%' && nametemplate[i+1] == 's')
      { 
	ps = 1;
	break;
      }

      /* note that the following will _not_ read beyond oldfile's end. */

      if(lmatch && nametemplate[i] != oldfile[i])
	lmatch = 0;
    }

    if(ps)
    {
      
      /* If we had a "%s", check the rest. */
      
      /* now, for the right part: compare everything right from 
       * the "%s" to the final part of oldfile.
       * 
       * The logic here is as follows:
       * 
       * - We start reading from the end.
       * - There must be a match _right_ from the "%s",
       *   thus the i + 2.  
       * - If there was a left hand match, this stuff
       *   must not be counted again.  That's done by the
       *   condition (j >= (lmatch ? i : 0)).
       */
      
      rmatch = 1;

      for(j = mutt_strlen(oldfile) - 1, k = mutt_strlen(nametemplate) - 1 ;
	  j >= (lmatch ? i : 0) && k >= i + 2;
	  j--, k--)
      {
	if(nametemplate[k] != oldfile[j])
	{
	  rmatch = 0;
	  break;
	}
      }
      
      /* Now, check if we had a full match. */
      
      if(k >= i + 2)
	rmatch = 0;
      
      if(lmatch) *left = 0;
      else strnfcpy(left, nametemplate, sizeof(left), i);
      
      if(rmatch) *right = 0;
      else strfcpy(right, nametemplate + i + 2, sizeof(right));
      
      snprintf(newfile, nflen, "%s%s%s", left, oldfile, right);
    }
    else
    {
      /* no "%s" in the name template. */
      strfcpy(newfile, nametemplate, nflen);
    }
  }
  
  mutt_adv_mktemp(newfile, nflen);

  if(rmatch && lmatch)
    return 0;
  else 
    return 1;
  
}
Пример #5
0
static void set_key(char *key, int index)
{
	strnfcpy(saved_key, key, PLAINTEXT_LENGTH);
	saved_key_len = strlen(saved_key);
}