Пример #1
0
/*
 * upap_sauthreq - Send an Authenticate-Request.
 */
static void
upap_sauthreq(upap_state *u)
{
  u_char *outp;
  int outlen;

  outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) 
         + u->us_userlen + u->us_passwdlen;
  outp = outpacket_buf[u->us_unit];

  MAKEHEADER(outp, PPP_PAP);

  PUTCHAR(UPAP_AUTHREQ, outp);
  PUTCHAR(++u->us_id, outp);
  PUTSHORT(outlen, outp);
  PUTCHAR(u->us_userlen, outp);
  BCOPY(u->us_user, outp, u->us_userlen);
  INCPTR(u->us_userlen, outp);
  PUTCHAR(u->us_passwdlen, outp);
  BCOPY(u->us_passwd, outp, u->us_passwdlen);

  pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN);

  UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d\n", u->us_id));

  TIMEOUT(upap_timeout, u, u->us_timeouttime);
  ++u->us_transmits;
  u->us_clientstate = UPAPCS_AUTHREQ;
}
Пример #2
0
Файл: chap.c Проект: AoLaD/rtems
/* ARGSUSED */
static void
ChapSendResponse(
    chap_state *cstate)
{
    u_char *outp;
    int outlen, md_len, name_len;

    md_len = cstate->resp_length;
    name_len = strlen(cstate->resp_name);
    outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);

    PUTCHAR(CHAP_RESPONSE, outp);	/* we are a response */
    PUTCHAR(cstate->resp_id, outp);	/* copy id from challenge packet */
    PUTSHORT(outlen, outp);		/* packet length */

    PUTCHAR(md_len, outp);		/* length of MD */
    BCOPY(cstate->response, outp, md_len);	/* copy MD to buffer */
    INCPTR(md_len, outp);

    BCOPY(cstate->resp_name, outp, name_len); /* append our name */

    /* send the packet */
    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);

    cstate->clientstate = CHAPCS_RESPONSE;
    TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime);
    ++cstate->resp_transmits;
}
Пример #3
0
Файл: chap.c Проект: AoLaD/rtems
/*
 * ChapSendChallenge - Send an Authenticate challenge.
 */
static void
ChapSendChallenge(
    chap_state *cstate)
{
    u_char *outp;
    int chal_len, name_len;
    int outlen;

    chal_len = cstate->chal_len;
    name_len = strlen(cstate->chal_name);
    outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);		/* paste in a CHAP header */

    PUTCHAR(CHAP_CHALLENGE, outp);
    PUTCHAR(cstate->chal_id, outp);
    PUTSHORT(outlen, outp);

    PUTCHAR(chal_len, outp);		/* put length of challenge */
    BCOPY(cstate->challenge, outp, chal_len);
    INCPTR(chal_len, outp);

    BCOPY(cstate->chal_name, outp, name_len);	/* append hostname */

    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);

    TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime);
    ++cstate->chal_transmits;
}
Пример #4
0
Файл: auth.c Проект: 10code/lwip
/*
 * get_secret - open the CHAP secret file and return the secret
 * for authenticating the given client on the given server.
 * (We could be either client or server).
 */
int
get_secret(int unit, char *client, char *server, char *secret, int *secret_len, int save_addrs)
{
#if 1
  int len;
  struct wordlist *addrs;

  LWIP_UNUSED_ARG(unit);
  LWIP_UNUSED_ARG(server);
  LWIP_UNUSED_ARG(save_addrs);

  addrs = NULL;

  if(!client || !client[0] || strcmp(client, ppp_settings.user)) {
    return 0;
  }

  len = (int)strlen(ppp_settings.passwd);
  if (len > MAXSECRETLEN) {
    AUTHDEBUG(LOG_ERR, ("Secret for %s on %s is too long\n", client, server));
    len = MAXSECRETLEN;
  }

  BCOPY(ppp_settings.passwd, secret, len);
  *secret_len = len;

  return 1;
#else
  int ret = 0, len;
  struct wordlist *addrs;
  char secbuf[MAXWORDLEN];
  
  addrs = NULL;
  secbuf[0] = 0;

  /* XXX Find secret. */
  if (ret < 0) {
    return 0;
  }

  if (save_addrs) {
    set_allowed_addrs(unit, addrs);
  }

  len = strlen(secbuf);
  if (len > MAXSECRETLEN) {
    AUTHDEBUG(LOG_ERR, ("Secret for %s on %s is too long\n", client, server));
    len = MAXSECRETLEN;
  }

  BCOPY(secbuf, secret, len);
  BZERO(secbuf, sizeof(secbuf));
  *secret_len = len;

  return 1;
#endif
}
Пример #5
0
Файл: chap.c Проект: AoLaD/rtems
/*
 * ChapSendStatus - Send a status response (ack or nak).
 */
static void
ChapSendStatus(
    chap_state *cstate,
    int code)
{
    u_char *outp;
    int outlen, msglen;
    char msg[256];

    if (code == CHAP_SUCCESS)
	slprintf(msg, sizeof(msg), "Welcome to %s.", hostname);
    else
	slprintf(msg, sizeof(msg), "I don't like you.  Go 'way.");
    msglen = strlen(msg);

    outlen = CHAP_HEADERLEN + msglen;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);	/* paste in a header */

    PUTCHAR(code, outp);
    PUTCHAR(cstate->chal_id, outp);
    PUTSHORT(outlen, outp);
    BCOPY(msg, outp, msglen);
    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
}
Пример #6
0
static void push_in_progress(ptr_t p)
{
  if (n_in_progress >= in_progress_size) {
    ptr_t * new_in_progress_space;

    if (NULL == in_progress_space) {
      in_progress_size = ROUNDUP_PAGESIZE_IF_MMAP(INITIAL_IN_PROGRESS
                                                        * sizeof(ptr_t))
                                / sizeof(ptr_t);
      new_in_progress_space =
                        (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t));
    } else {
      in_progress_size *= 2;
      new_in_progress_space = (ptr_t *)
                                GET_MEM(in_progress_size * sizeof(ptr_t));
      if (new_in_progress_space != NULL)
        BCOPY(in_progress_space, new_in_progress_space,
              n_in_progress * sizeof(ptr_t));
    }
    GC_add_to_our_memory((ptr_t)new_in_progress_space,
                         in_progress_size * sizeof(ptr_t));
#   ifndef GWW_VDB
      GC_scratch_recycle_no_gww(in_progress_space,
                                n_in_progress * sizeof(ptr_t));
#   elif defined(LINT2)
      /* TODO: implement GWW-aware recycling as in alloc_mark_stack */
      GC_noop1((word)in_progress_space);
#   endif
    in_progress_space = new_in_progress_space;
  }
  if (in_progress_space == 0)
      ABORT("MAKE_BACK_GRAPH: Out of in-progress space: "
            "Huge linear data structure?");
  in_progress_space[n_in_progress++] = p;
}
Пример #7
0
size_t    rawDataPuts(RawData *raw_data, const offset_t offset, const char *src)
{
    size_t len;

    if(raw_data->max_size <= offset)
    {
        dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataPuts: max_size %d, but access offset %d overflow\n", raw_data->max_size, offset);
        return 0;
    }

    if(raw_data->max_size <= offset + strlen(src))
    {
        dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataPuts: max_size %d, but access offset(%d) + strlen(%d) = %d  overflow\n",
                            raw_data->max_size, offset, strlen(src), offset + strlen(src));
    }

    len = DMIN(strlen(src), raw_data->max_size - offset);
    BCOPY(src, raw_data->buffer + offset, len);
    if(offset + len > raw_data->cur_size)
    {
        raw_data->cur_size = offset + len;
    }
    RAWDATA_SET_DIRTY(raw_data);

    return len;
}
Пример #8
0
const char * formatGetString (BUFFER_PTR buffer)
{
#define CBUF_LEN 100
  static int bufLen = CBUF_LEN;
  static char *charBuffer = NULL;
  if (charBuffer == NULL) charBuffer = (char *)malloc(bufLen);

  int length = formatGetInt(buffer);

  if (length == 0) {
    charBuffer[0] = '\0';
    formatGetChar(buffer); // The 'Z'
  } else {
    if (length >= bufLen) {
      /* Need to re-allocate this array, with room for a null termination */
      free(charBuffer);
      bufLen = length+1;
      charBuffer = (char *)malloc(bufLen);
    }
    BCOPY(buffer->buffer+buffer->bstart, charBuffer, length);
    buffer->bstart += length;
    charBuffer[length] = '\0';
  }
  return charBuffer;
}
Пример #9
0
static void push_in_progress(ptr_t p)
{
  if (n_in_progress >= in_progress_size) {
    if (in_progress_size == 0) {
      in_progress_size = INITIAL_IN_PROGRESS;
      in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t));
      GC_add_to_our_memory((ptr_t)in_progress_space,
      			   in_progress_size * sizeof(ptr_t));
    } else {
      ptr_t * new_in_progress_space;
      in_progress_size *= 2;
      new_in_progress_space = (ptr_t *)
	      			GET_MEM(in_progress_size * sizeof(ptr_t));
      GC_add_to_our_memory((ptr_t)new_in_progress_space,
      			   in_progress_size * sizeof(ptr_t));
      BCOPY(in_progress_space, new_in_progress_space,
	    n_in_progress * sizeof(ptr_t));
      in_progress_space = new_in_progress_space;
      /* FIXME: This just drops the old space.	*/
    }
  }
  if (in_progress_space == 0)
      ABORT("MAKE_BACK_GRAPH: Out of in-progress space: "
	    "Huge linear data structure?");
  in_progress_space[n_in_progress++] = p;
}
Пример #10
0
void
map_cpus_to_prstatus_kdump_cmprs(void)
{
	void **nt_ptr;
	int online, i, j, nrcpus;
	size_t size;

	if (!(online = get_cpus_online()) || (online == kt->cpus))
		return;

	if (CRASHDEBUG(1))
		error(INFO,
		    "cpus: %d online: %d NT_PRSTATUS notes: %d (remapping)\n",
			kt->cpus, online, dd->num_prstatus_notes);

	size = NR_CPUS * sizeof(void *);

	nt_ptr = (void **)GETBUF(size);
	BCOPY(dd->nt_prstatus_percpu, nt_ptr, size);
	BZERO(dd->nt_prstatus_percpu, size);

	/*
	 *  Re-populate the array with the notes mapping to online cpus
	 */
	nrcpus = (kt->kernel_NR_CPUS ? kt->kernel_NR_CPUS : NR_CPUS);

	for (i = 0, j = 0; i < nrcpus; i++) {
		if (in_cpu_map(ONLINE, i))
			dd->nt_prstatus_percpu[i] = nt_ptr[j++];
	}

	FREEBUF(nt_ptr);
}
Пример #11
0
void
ChapMS( chap_state *cstate, char *rchallenge, int rchallenge_len, char *secret, int secret_len)
{
  MS_ChapResponse response;
#ifdef MSLANMAN
  extern int ms_lanman;
#endif

#if 0
  CHAPDEBUG(LOG_INFO, ("ChapMS: secret is '%.*s'\n", secret_len, secret));
#endif
  BZERO(&response, sizeof(response));

  /* Calculate both always */
  ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, &response);

#ifdef MSLANMAN
  ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, &response);

  /* prefered method is set by option  */
  response.UseNT = !ms_lanman;
#else
  response.UseNT = 1;
#endif

  BCOPY(&response, cstate->response, MS_CHAP_RESPONSE_LEN);
  cstate->resp_length = MS_CHAP_RESPONSE_LEN;
}
Пример #12
0
JNIEXPORT jstring JNICALL Java_ipc_java_primFmttrs_formatGetString (JNIEnv *env,
							   jclass c, jlong buf)
{
  BUFFER_PTR buffer = (BUFFER_PTR)(size_t)buf;
  int length = formatGetInt(buffer);
#define CBUF_LEN 100
  char charBuffer[CBUF_LEN], *tmp;
  jstring theString;

  tmp = charBuffer;
  if (length == 0) {
    charBuffer[0] = '\0';
    formatGetChar(buffer);
  } else {
    if (length >= CBUF_LEN) {
      /* Need to allocate this array because NewStringUTF needs a 
	 null-terminated string.  Sigh... */
      tmp = (char *)malloc(length+1);
    }
    BCOPY(buffer->buffer+buffer->bstart, tmp, length);
    buffer->bstart += length;
    tmp[length] = '\0';
  }
  theString = (*env)->NewStringUTF(env, tmp);
  if (length >= CBUF_LEN) free(tmp);
  return theString;
}
Пример #13
0
/*
 * The peer has been successfully authenticated using `protocol'.
 */
void
auth_peer_success(int unit, u16_t protocol, char *name, int namelen)
{
  int pbit;

  AUTHDEBUG((LOG_INFO, "auth_peer_success: %d proto=%X\n", unit, protocol));
  switch (protocol) {
    case PPP_CHAP:
      pbit = CHAP_PEER;
      break;
    case PPP_PAP:
      pbit = PAP_PEER;
      break;
    default:
      AUTHDEBUG((LOG_WARNING, "auth_peer_success: unknown protocol %x\n", protocol));
      return;
  }

  /*
   * Save the authenticated name of the peer for later.
   */
  if (namelen > sizeof(peer_authname) - 1) {
    namelen = sizeof(peer_authname) - 1;
  }
  BCOPY(name, peer_authname, namelen);
  peer_authname[namelen] = 0;

  /*
   * If there is no more authentication still to be done,
   * proceed to the network (or callback) phase.
   */
  if ((auth_pending[unit] &= ~pbit) == 0) {
    network_phase(unit);
  }
}
Пример #14
0
static void
ChallengeResponse(u_char *challenge,
                  u_char PasswordHash[MD4_SIGNATURE_SIZE],
                  u_char response[24])
{
    u_char    ZPasswordHash[21];

    BZERO(ZPasswordHash, sizeof(ZPasswordHash));
    BCOPY(PasswordHash, ZPasswordHash, MD4_SIGNATURE_SIZE);

#if 0
    dbglog("ChallengeResponse - ZPasswordHash %.*B",
           sizeof(ZPasswordHash), ZPasswordHash);
#endif

    (void) DesSetkey(ZPasswordHash + 0);
    DesEncrypt(challenge, response + 0);
    (void) DesSetkey(ZPasswordHash + 7);
    DesEncrypt(challenge, response + 8);
    (void) DesSetkey(ZPasswordHash + 14);
    DesEncrypt(challenge, response + 16);

#if 0
    dbglog("ChallengeResponse - response %.24B", response);
#endif
}
Пример #15
0
size_t    rawDataWrite(RawData *raw_data, const offset_t offset, const void *src, size_t size, size_t nmemb)
{
    size_t count;
    size_t len;

    if(raw_data->max_size <= offset)
    {
        dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataWrite: max_size %d, but access offset %d overflow\n", raw_data->max_size, offset);
        return 0;
    }

    if(0 == size || 0 == nmemb)
    {
        return 0;
    }

    if(raw_data->max_size <= offset + size * nmemb)
    {
        dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawDataWrite: max_size %d, but access offset(%d) + size(%d) * nmemb(%d) = %d  overflow\n",
                            raw_data->max_size, offset, size, nmemb, offset + size * nmemb);
    }

    count = DMIN(nmemb, (raw_data->max_size - offset)/size);
    len = size * count;
    BCOPY(src, raw_data->buffer + offset, len);
    if(offset + len > raw_data->cur_size)
    {
        raw_data->cur_size = offset + len;
    }
    RAWDATA_SET_DIRTY(raw_data);

    return count;
}
Пример #16
0
const void *x_ipc_hashTableInsert(const void *key, int32 keySize, 
			    const void *item, HASH_TABLE_PTR table)
{
  const char *oldData;
  int32 hash, location;
  HASH_ELEM_PTR tmp, element;
  char *keyPtr=NULL;
  
  hash = (*table->hashFunc)(key);
  location = hash % table->size;
  
  tmp = table->table[location];
  if (tmp) {
    tmp = x_ipc_findElement(table->eqFunc, tmp, key);
    if (tmp) {
      /* replace item with new information */
      oldData = tmp->data;
      tmp->data = (const char *)item;
      return oldData;
    }
  }
  
  element = NEW(HASH_ELEM_TYPE);
  keyPtr = (char *)x_ipcMalloc((unsigned)keySize);
  BCOPY(key, keyPtr, keySize);
  element->key = (const char *) keyPtr;
  element->data = (const char *)item;
  element->next = table->table[location];
  table->table[location] = element;
  
  return NULL;
}
Пример #17
0
void 
mfs_auditview_to_mfs_auditview_32(struct mfs_auditview *vbl, struct mfs_auditview_32 *vbl_32)
{
	vbl_32->namlen = vbl->namlen;
	tbs_uuid_s_to_tbs_uuid_s_32(&vbl->viewuuid, &vbl_32->viewuuid);
	BCOPY(&vbl->name[0], &vbl_32->name[0], vbl->namlen+1);
}
Пример #18
0
  static GC_bool ensure_toggleref_capacity(int capacity_inc)
  {
    GC_ASSERT(capacity_inc >= 0);
    if (NULL == GC_toggleref_arr) {
      GC_toggleref_array_capacity = 32; /* initial capacity */
      GC_toggleref_arr = GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
                        GC_toggleref_array_capacity * sizeof(GCToggleRef),
                        NORMAL);
      if (NULL == GC_toggleref_arr)
        return FALSE;
    }
    if ((unsigned)GC_toggleref_array_size + (unsigned)capacity_inc
        >= (unsigned)GC_toggleref_array_capacity) {
      GCToggleRef *new_array;
      while ((unsigned)GC_toggleref_array_capacity
              < (unsigned)GC_toggleref_array_size + (unsigned)capacity_inc) {
        GC_toggleref_array_capacity *= 2;
        if (GC_toggleref_array_capacity < 0) /* overflow */
          return FALSE;
      }

      new_array = GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
                        GC_toggleref_array_capacity * sizeof(GCToggleRef),
                        NORMAL);
      if (NULL == new_array)
        return FALSE;
      BCOPY(GC_toggleref_arr, new_array,
            GC_toggleref_array_size * sizeof(GCToggleRef));
      GC_INTERNAL_FREE(GC_toggleref_arr);
      GC_toggleref_arr = new_array;
    }
    return TRUE;
  }
Пример #19
0
/*
 * Set mppe_xxxx_key from the NTPasswordHashHash.
 * RFC 2548 (RADIUS support) requires us to export this function (ugh).
 */
void
mppe_set_keys(u_char *rchallenge, u_char PasswordHashHash[MD4_SIGNATURE_SIZE])
{
    SHA1_CTX	sha1Context;
    u_char	Digest[SHA1_SIGNATURE_SIZE];	/* >= MPPE_MAX_KEY_LEN */

    SHA1_Init(&sha1Context);
    SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
    SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
    SHA1_Update(&sha1Context, rchallenge, 8);
    SHA1_Final(Digest, &sha1Context);

    /* Same key in both directions. */
    BCOPY(Digest, mppe_send_key, sizeof(mppe_send_key));
    BCOPY(Digest, mppe_recv_key, sizeof(mppe_recv_key));
}
Пример #20
0
void * GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
{
    void * base = GC_base(p);
    ptr_t clobbered;
    void * result;
    size_t copy_sz = lb;
    size_t old_sz;
    hdr * hhdr;
    
    if (p == 0) return(GC_debug_malloc(lb, OPT_RA s, i));
    if (base == 0) {
        GC_err_printf("Attempt to reallocate invalid pointer %p\n", p);
        ABORT("realloc(invalid pointer)");
    }
    if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
        GC_err_printf(
        	"GC_debug_realloc called on pointer %p wo debugging info\n", p);
        return(GC_realloc(p, lb));
    }
    hhdr = HDR(base);
    switch (hhdr -> hb_obj_kind) {
#    ifdef STUBBORN_ALLOC
      case STUBBORN:
        result = GC_debug_malloc_stubborn(lb, OPT_RA s, i);
        break;
#    endif
      case NORMAL:
        result = GC_debug_malloc(lb, OPT_RA s, i);
        break;
      case PTRFREE:
        result = GC_debug_malloc_atomic(lb, OPT_RA s, i);
        break;
      case UNCOLLECTABLE:
	result = GC_debug_malloc_uncollectable(lb, OPT_RA s, i);
 	break;
#    ifdef ATOMIC_UNCOLLECTABLE
      case AUNCOLLECTABLE:
	result = GC_debug_malloc_atomic_uncollectable(lb, OPT_RA s, i);
	break;
#    endif
      default:
        GC_err_printf("GC_debug_realloc: encountered bad kind\n");
        ABORT("bad kind");
    }
#   ifdef SHORT_DBG_HDRS
      old_sz = GC_size(base) - sizeof(oh);
#   else
      clobbered = GC_check_annotated_obj((oh *)base);
      if (clobbered != 0) {
        GC_err_printf("GC_debug_realloc: found smashed location at ");
        GC_print_smashed_obj(p, clobbered);
      }
      old_sz = ((oh *)base) -> oh_sz;
#   endif
    if (old_sz < copy_sz) copy_sz = old_sz;
    if (result == 0) return(0);
    BCOPY(p, result,  copy_sz);
    GC_debug_free(p);
    return(result);
}
Пример #21
0
float DecodeDouble(GENERIC_DATA_PTR DataArray, int32 Start)
{ 
  double Double;
  
  DataArray += Start;
  BCOPY(DataArray, (char *)&Double, sizeof(double));
  return Double;
}
Пример #22
0
/* LISP floating point numbers are equivalent to C "double" format */
void EncodeFloat(double Float, GENERIC_DATA_PTR DataArray, int32 Start)
{ 
  float RealFloat;
  
  DataArray += Start;
  RealFloat = (float)Float;
  BCOPY((char *)&RealFloat, DataArray, sizeof(float));
}
Пример #23
0
/* LISP floating point numbers are equivalent to C "double" format */
double DecodeFloat(GENERIC_DATA_PTR DataArray, int32 Start)
{ 
  float Float;
  
  DataArray += Start;
  BCOPY(DataArray, (char *)&Float, sizeof(float));
  return (double)Float;
}
int hapsLocalLocus::typeSpecificCopy(localLocus *s)
{
	hapsLocalLocus *src=(hapsLocalLocus *)s;
	if (localLocus::typeSpecificCopy(src)==0)
		return 0;
	BCOPY(rsName,src->rsName);
	return 1;
}
Пример #25
0
STATIC int
vnlayer_unpack_fh(
    __u32 *fh,
    int len,                            /* counted in units of 4-bytes */
    int fhtype,
    int fidlen,
    MDKI_FID_T *lfidp,
    MDKI_FID_T *plfidp
)
{
    if (len * sizeof(*fh) < fhtype) {
        /*
         * we put the size in the type on the way out;
         * make sure we have enough data returning now
         */
        MDKI_VFS_LOG(VFS_LOG_ESTALE,
                     "%s: FH doesn't have enough data for type:"
                     " has %d need %d\n",
                     __func__, (int)(len * sizeof(*fh)), fhtype);
        return -EINVAL;
    }

    if ((fhtype & 1) != 0) {
        /*
         * The type/length must be even (there are two equal-sized
         * halves in the payload).  Somebody might be fabricating file
         * handles?
         */
        MDKI_VFS_LOG(VFS_LOG_ESTALE,
                     "%s: FH type (%d) not even\n", __func__, fhtype);
        return -EINVAL;
    }

    if (lfidp != NULL) {
        /* object */
        lfidp->fid_len = fidlen;
        BCOPY(fh, lfidp->fid_data, fidlen);
    }
    if (plfidp != NULL) {
        /* parent */
        plfidp->fid_len = fidlen;
        BCOPY(((caddr_t)fh) + fidlen, plfidp->fid_data, fidlen);
    }
    return 0;
}
Пример #26
0
void
mvfs_credutl_sid_s_to_credutl_sid_s_32(struct credutl_sid_s *vbl, struct credutl_sid_s *vbl_32)
{   
    vbl_32->length = vbl->length;
    vbl_32->type = vbl->type;

	BCOPY((caddr_t)&vbl->sid[0], (caddr_t)&vbl_32->sid[0],
		sizeof(vbl->sid));
}
Пример #27
0
GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
{
    void * base;
    void * result;
    hdr * hhdr;
    if (p == 0)
      return(GC_debug_malloc(lb, OPT_RA s, i));

    base = GC_base(p);
    if (base == 0) {
        GC_err_printf("Attempt to reallocate invalid pointer %p\n", p);
        ABORT("Invalid pointer passed to realloc()");
    }
    if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
        GC_err_printf(
              "GC_debug_realloc called on pointer %p w/o debugging info\n", p);
        return(GC_realloc(p, lb));
    }
    hhdr = HDR(base);
    switch (hhdr -> hb_obj_kind) {
#    ifdef STUBBORN_ALLOC
      case STUBBORN:
        result = GC_debug_malloc_stubborn(lb, OPT_RA s, i);
        break;
#    endif
      case NORMAL:
        result = GC_debug_malloc(lb, OPT_RA s, i);
        break;
      case PTRFREE:
        result = GC_debug_malloc_atomic(lb, OPT_RA s, i);
        break;
      case UNCOLLECTABLE:
        result = GC_debug_malloc_uncollectable(lb, OPT_RA s, i);
        break;
#    ifdef ATOMIC_UNCOLLECTABLE
      case AUNCOLLECTABLE:
        result = GC_debug_malloc_atomic_uncollectable(lb, OPT_RA s, i);
        break;
#    endif
      default:
        result = NULL; /* initialized to prevent warning. */
        GC_err_printf("GC_debug_realloc: encountered bad kind\n");
        ABORT("Bad kind");
    }

    if (result != NULL) {
      size_t old_sz;
#     ifdef SHORT_DBG_HDRS
        old_sz = GC_size(base) - sizeof(oh);
#     else
        old_sz = ((oh *)base) -> oh_sz;
#     endif
      BCOPY(p, result, old_sz < lb ? old_sz : lb);
      GC_debug_free(p);
    }
    return(result);
}
Пример #28
0
void
process_fddi(register u_char *u, register const struct pcap_pkthdr *h,
    register const u_char *p)
{
	register struct fddi_header *fh;
	register struct ether_arp *ea;
	register u_char *sea, *sha;
	register time_t t;
	u_int32_t sia;

	fh = (struct fddi_header *)p;
	ea = (struct ether_arp *)(fh + 1);

	if (!swapped) {
		bit_reverse(fh->src, 6);
		bit_reverse(fh->dst, 6);
	}
	if (!sanity_fddi(fh, ea, h->caplen))
		return;

	/* Source MAC hardware ethernet address */
	sea = (u_char *)fh->src;

	/* Source ARP ethernet address */
	sha = (u_char *)SHA(ea);

	/* Source ARP ip address */
	BCOPY(SPA(ea), &sia, 4);

	/* Watch for bogons */
	if (isbogon(sia)) {
		dosyslog(LOG_INFO, "bogon", sia, sea, sha);
		return;
	}

	/* Watch for ethernet broadcast */
	if (MEMCMP(sea, zero, 6) == 0 || MEMCMP(sea, allones, 6) == 0 ||
	    MEMCMP(sha, zero, 6) == 0 || MEMCMP(sha, allones, 6) == 0) {
		dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha);
		return;
	}

	/* Double check ethernet addresses */
	if (MEMCMP(sea, sha, 6) != 0) {
		dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha);
		return;
	}

	/* Got a live one */
	t = h->ts.tv_sec;
	can_checkpoint = 0;
	if (!ent_add(sia, sea, t, NULL))
		syslog(LOG_ERR, "ent_add(%s, %s, %ld) failed",
		    intoa(sia), e2str(sea), t);
	can_checkpoint = 1;
}
Пример #29
0
DATA_MSG_PTR x_ipc_dataMsgReplaceClassData(CONST_FORMAT_PTR classFormat,
				     void *data,
				     DATA_MSG_PTR dataMsg,
				     CONST_FORMAT_PTR msgFormat)
{
#ifdef UNUSED_PRAGMA
#pragma unused(msgFormat)
#endif
  DATA_MSG_PTR newDataMsg;
  int32 classTotal=0;
  
  if (data && classFormat)
    classTotal = x_ipc_bufferSize(classFormat, data);
  
  newDataMsg = x_ipc_dataMsgAlloc(sizeof(DATA_MSG_TYPE)+classTotal);
  
  /* 3-Sep-90: fedor: this should work because class info is in the
     dataMsg struture as the last item. */
  
  BCOPY((char *)dataMsg, (char *)newDataMsg, sizeof(DATA_MSG_TYPE));
  
  if (classTotal) {
    newDataMsg->classData = ((char *)newDataMsg + sizeof(DATA_MSG_TYPE));
    x_ipc_encodeData(classFormat, data, newDataMsg->classData, 0, classTotal);
    newDataMsg->classByteOrder = BYTE_ORDER;
  }
  else
    newDataMsg->classData = NULL;
  
  /* reset msgData pointer */
  newDataMsg->msgData = dataMsg->msgData;
  newDataMsg->dataStruct = dataMsg->dataStruct;
  dataMsg->msgData = NULL;
  
  /* Need to copy the vector data. */
  if (dataMsg->vec != NULL)
    newDataMsg->vec = x_ipc_copyVectorization(dataMsg->vec,0);
  else {
    X_IPC_MOD_ERROR("Internal Error: Missing data Vector\n");
    return NULL;
  }
  
  /* set refCount */
  newDataMsg->dataRefCountPtr = dataMsg->dataRefCountPtr;
  if ( newDataMsg->dataRefCountPtr != NULL)
    (*(newDataMsg->dataRefCountPtr))++;
  newDataMsg->refCount = 0;
  
  newDataMsg->classTotal = classTotal;
  
  if (x_ipc_dataMsgFree(dataMsg) != NULL)
    dataMsg->msgData = newDataMsg->msgData;
  
  return newDataMsg;
}
Пример #30
0
/* Find string with the given enumerated value, and copy the string into
   the (already allocated) LISP vector */
char *enumValNameString (CONST_FORMAT_PTR format, int32 enumVal)
{
  char *name;

  if (format->formatter.a[0].i > 2 &&
      0 <= enumVal && enumVal <= ENUM_MAX_VAL(format)) {
    name = format->formatter.a[enumVal+2].f->formatter.name;
    BCOPY(name, (char *)Vecdata(SymbolValue(lisp_value(0))), strlen(name));
  }  
  return (char *)SymbolValue(lisp_value(0));
}