Beispiel #1
0
void *
__mpx_wrapper_malloc (size_t size)
{
  void *p = (void *)malloc (size);
  if (!p) return __bnd_null_ptr_bounds (p);
  return __bnd_set_ptr_bounds (p, size);
}
int mpx_test (int argc, const char **argv)
{
  int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
  p = buf;
  __bnd_store_ptr_bounds ((void **)&p, p1);
  return 0;
}
Beispiel #3
0
void *
__mpx_wrapper_calloc (size_t n_elements, size_t element_size)
{
  void *p = calloc (n_elements, element_size);
  if (!p)
    return __bnd_null_ptr_bounds (p);
  return __bnd_set_ptr_bounds (p, n_elements * element_size);
}
Beispiel #4
0
void *
__mpx_wrapper_mmap (void *addr, size_t length, int prot, int flags,
		    int fd, off_t offset)
{
  void *p = mmap (addr, length, prot, flags, fd, offset);
  if (!p) return __bnd_null_ptr_bounds (p);
  return __bnd_set_ptr_bounds (p, length);
}
Beispiel #5
0
int mpx_test (int argc, const char **argv)
{
  int *p = __bnd_set_ptr_bounds (buf + 1, 40);
  rd (buf, p, 0);
  rd (buf, p, 9);

  return 0;
}
int check_authentication(char *password) {
	int auth_flag = 0;
	char password_buffer[16];
	protected_buffer = __bnd_set_ptr_bounds(password_buffer, 16);
	string_copy(protected_buffer, password);

	if(strcmp(password_buffer, "brillig") == 0)
		auth_flag = 1;
	if(strcmp(password_buffer, "outgrabe") == 0)
		auth_flag = 1;

	return auth_flag;
}
Beispiel #7
0
int
mpx_test (int argc, const char **argv)
{
  void **arr = 0;
  posix_memalign ((void **) (&arr),
           1UL << (MPX_NUM_L2_BITS + MPX_NUM_IGN_BITS),
           2 * bt_num_of_elems * sizeof (void *));
  void **src = arr, **dst = arr, **ptr = arr;
  src += 10;
  dst += 1;
  ptr += bt_num_of_elems + 100;
  ptr[0] = __bnd_set_ptr_bounds (arr + 1, sizeof (void *) + 1);
  memmove (dst, src, 5 * sizeof (void *));
  return 0;
}
Beispiel #8
0
void *
__mpx_wrapper_realloc (void *ptr, size_t n)
{
  if (!ptr)
    return __mpx_wrapper_malloc (n);

  /* We don't kwnow how much data is copied by realloc
     and therefore may check only lower bounds.  */
  __bnd_chk_ptr_lbounds (ptr);
  ptr = realloc (ptr, n);

  if (!ptr)
    return __bnd_null_ptr_bounds (ptr);

  return __bnd_set_ptr_bounds (ptr, n);
}
int mpx_test (int argc, const char **argv)
{
  assert (buf + 10 == __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10));
  return 0;
}