예제 #1
0
secerrno_enum_type sec_oem_data_set (void *input_data, unsigned int input_len,
  void **output_handle)
{
  unsigned int *stored_handle;

  if ((NULL == input_data) || (0 == input_len) || (NULL == output_handle))
    return E_INVALID_ARG;

  /* We need to store the data length, so allocate extra bytes. There will
  ** be no alignment problems as long as sizeof(int) is four or less, since
  ** UxMalloc allocates on four-byte boundaries.
  */
  ASSERT (sizeof(unsigned int) <= 4);

  stored_handle = UxMalloc (input_len + sizeof(unsigned int), UX_ALLOC_LOCAL);

  if (NULL == stored_handle)
    return E_NO_MEMORY;

  /* This function merely makes a copy of the input data and returns a
  ** pointer to the copy. An obfuscation operation can be performed instead,
  ** if desired. 
  */

  *stored_handle = input_len;

  *output_handle = (void *) (stored_handle + 1);

  memcpy (*output_handle, input_data, input_len);

  memset (input_data, input_len, 0x00);

  return E_SUCCESS;
}
예제 #2
0
파일: UxMethod.c 프로젝트: nagyistge/ctn
/*------------------------------------------------------------------------
 * NAME:	UxMessageIndex
 * INPUT:	char* name; -- name of a method being registered.
 * RETURNS:	A unique id number for this name.
 * DESCRIPTION:
 *	Assigns a unique integer to a message name.
 *	Must return the same id for all calls with the same name.
 *
 *	This is used while rgistering methods at startup time.
 *	The result is used when method calls are made
 *	(see UxMethodLookup).  If a very large number of method names
 *	are being used, initialization could be speeded up by making
 *	this function faster (by sorting or hashing the names).
 *
 * LAST REV:	June 92	fix3574		Created.
 *------------------------------------------------------------------------*/
#ifdef _NO_PROTO
int
UxMessageIndex(name)
char *name;
#else				/* _NO_PROTO */
int
UxMessageIndex(char *name)
#endif				/* _NO_PROTO */
{
    int mid;

    for (mid = 0; mid < NumNames; mid++) {
	if (UxStrEqual(Names[mid], name)) {
	    return mid;
	}
    }
    if (mid >= NameLen) {
	if (NameLen == 0) {
	    Names = (char **) UxMalloc((NameLen = 64) * sizeof(char *));
	} else {
	    Names = (char **) UxRealloc(Names,
					(NameLen *= 2) * sizeof(char *));
	}
    }
    Names[NumNames] = (char *) UxMalloc(strlen(name) + 1);
    strcpy(Names[NumNames], name);
    return NumNames++;
}
예제 #3
0
secerrno_enum_type sec_oem_data_dup (void *input_handle, void **output_handle)
{
  unsigned int *stored_data;
  unsigned int *new_handle;

  if ((NULL == input_handle) || (NULL == output_handle))
    return E_INVALID_ARG;

  stored_data = ((unsigned int *) input_handle) - 1;

  new_handle = UxMalloc (*stored_data + sizeof(unsigned int), UX_ALLOC_LOCAL);

  if (NULL == new_handle)
    return E_NO_MEMORY;

  memcpy (new_handle, stored_data, *stored_data + sizeof(unsigned int));

  *output_handle = (void *) (new_handle + 1);

  return E_SUCCESS;
}