• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ os_realloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中os_realloc函数的典型用法代码示例。如果您正苦于以下问题:C++ os_realloc函数的具体用法?C++ os_realloc怎么用?C++ os_realloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了os_realloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fd_log_debug

struct radius_attr_hdr *radius_msg_add_attr(struct radius_msg *msg, u8 type,
					    const u8 *data, size_t data_len)
{
	size_t buf_needed;
	struct radius_attr_hdr *attr;

	if (data_len > RADIUS_MAX_ATTR_LEN) {
		fd_log_debug("radius_msg_add_attr: too long attribute (%lu bytes)",
		       (unsigned long) data_len);
		return NULL;
	}

	buf_needed = msg->buf_used + sizeof(*attr) + data_len;

	if (msg->buf_size < buf_needed) {
		/* allocate more space for message buffer */
		unsigned char *nbuf;
		size_t nlen = msg->buf_size;

		while (nlen < buf_needed)
			nlen *= 2;
		nbuf = os_realloc(msg->buf, nlen);
		if (nbuf == NULL)
			return NULL;
		msg->buf = nbuf;
		msg->hdr = (struct radius_hdr *) msg->buf;
		os_memset(msg->buf + msg->buf_size, 0, nlen - msg->buf_size);
		msg->buf_size = nlen;
	}

	attr = (struct radius_attr_hdr *) (msg->buf + msg->buf_used);
	attr->type = type;
	attr->length = sizeof(*attr) + data_len;
	if (data_len > 0)
		os_memcpy(attr + 1, data, data_len);

	msg->buf_used += sizeof(*attr) + data_len;

	if (radius_msg_add_attr_to_array(msg, attr))
		return NULL;

	return attr;
}
开发者ID:ClearwaterCore,项目名称:freeDiameter,代码行数:43,代码来源:radius.c


示例2: radius_msg_add_attr_to_array

static int radius_msg_add_attr_to_array(struct radius_msg *msg,
					struct radius_attr_hdr *attr)
{
	if (msg->attr_used >= msg->attr_size) {
		struct radius_attr_hdr **nattrs;
		int nlen = msg->attr_size * 2;

		nattrs = os_realloc(msg->attrs, nlen * sizeof(*msg->attrs));
		if (nattrs == NULL)
			return -1;

		msg->attrs = nattrs;
		msg->attr_size = nlen;
	}

	msg->attrs[msg->attr_used++] = attr;

	return 0;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:19,代码来源:radius.c


示例3: OS_MarkGroup

/* Mark rules that match specific group (for if_matched_group) */
int OS_MarkGroup(RuleNode *r_node, RuleInfo *orig_rule)
{
    /* If no r_node is given, get first node */
    if (r_node == NULL) {
        r_node = OS_GetFirstRule();
    }

    while (r_node) {
        if (OSMatch_Execute(r_node->ruleinfo->group,
                            strlen(r_node->ruleinfo->group),
                            orig_rule->if_matched_group)) {
            unsigned int rule_g = 0;
            if (r_node->ruleinfo->group_prev_matched) {
                while (r_node->ruleinfo->group_prev_matched[rule_g]) {
                    rule_g++;
                }
            }

            os_realloc(r_node->ruleinfo->group_prev_matched,
                       (rule_g + 2)*sizeof(OSList *),
                       r_node->ruleinfo->group_prev_matched);

            r_node->ruleinfo->group_prev_matched[rule_g] = NULL;
            r_node->ruleinfo->group_prev_matched[rule_g + 1] = NULL;

            /* Set the size */
            r_node->ruleinfo->group_prev_matched_sz = rule_g + 1;

            r_node->ruleinfo->group_prev_matched[rule_g] =
                orig_rule->group_search;
        }

        /* Check if the child has a rule */
        if (r_node->child) {
            OS_MarkGroup(r_node->child, orig_rule);
        }

        r_node = r_node->next;
    }

    return (0);
}
开发者ID:COLTONKERNS,项目名称:ossec-hids,代码行数:43,代码来源:rules_list.c


示例4: add_str

static void add_str(void *ctx_ptr, const char *fmt, ...)
{
	struct str_buf *str = ctx_ptr;
	va_list ap;
	char *n;
	int len;

	n = os_realloc(str->buf, str->len + MAX_STR + 2);
	if (n == NULL)
		return;
	str->buf = n;

	va_start(ap, fmt);
	len = vsnprintf(str->buf + str->len, MAX_STR, fmt, ap);
	va_end(ap);
	if (len >= MAX_STR)
		len = MAX_STR - 1;
	str->len += len;
	str->buf[str->len] = '\0';
}
开发者ID:2asoft,项目名称:freebsd,代码行数:20,代码来源:xml_libxml2.c


示例5: nss_io_send

static PRInt32 nss_io_send(PRFileDesc *fd, const void *buf, PRInt32 amount,
        PRIntn flags, PRIntervalTime timeout) {
    struct tls_connection *conn = (struct tls_connection *) fd->secret;
    u8 *nbuf;

    wpa_printf(MSG_DEBUG, "NSS: I/O %s", __func__);
    wpa_hexdump(MSG_MSGDUMP, "NSS: I/O send data", buf, amount);

    nbuf = os_realloc(conn->push_buf, conn->push_buf_len + amount);
    if (nbuf == NULL) {
        wpa_printf(MSG_ERROR, "NSS: Failed to allocate memory for the "
                "data to be sent");
        return PR_FAILURE;
    }
    os_memcpy(nbuf + conn->push_buf_len, buf, amount);
    conn->push_buf = nbuf;
    conn->push_buf_len += amount;

    return amount;
}
开发者ID:vk496,项目名称:reaver-wps-fork-t6x,代码行数:20,代码来源:tls_nss.c


示例6: radius_msg_add_attr_to_array

int radius_msg_add_attr_to_array(struct radius_msg *msg,
					struct radius_attr_hdr *attr)
{
	if (msg->attr_used >= msg->attr_size) {
		size_t *nattr_pos;
		int nlen = msg->attr_size * 2;

		nattr_pos = os_realloc(msg->attr_pos,
				       nlen * sizeof(*msg->attr_pos));
		if (nattr_pos == NULL)
			return -1;

		msg->attr_pos = nattr_pos;
		msg->attr_size = nlen;
	}

	msg->attr_pos[msg->attr_used++] = (unsigned char *) attr - msg->buf;

	return 0;
}
开发者ID:ClearwaterCore,项目名称:freeDiameter,代码行数:20,代码来源:radius.c


示例7: eloop_register_read_sock

int eloop_register_read_sock(int sock, eloop_sock_handler handler,
			     void *eloop_data, void *user_data)
{
	WSAEVENT event;
	struct eloop_sock *tmp;

	if (eloop_prepare_handles())
		return -1;

	event = WSACreateEvent();
	if (event == WSA_INVALID_EVENT) {
		printf("WSACreateEvent() failed: %d\n", WSAGetLastError());
		return -1;
	}

	if (WSAEventSelect(sock, event, FD_READ)) {
		printf("WSAEventSelect() failed: %d\n", WSAGetLastError());
		WSACloseEvent(event);
		return -1;
	}
	tmp = os_realloc(eloop.readers,
			 (eloop.reader_count + 1) * sizeof(struct eloop_sock));
	if (tmp == NULL) {
		WSAEventSelect(sock, event, 0);
		WSACloseEvent(event);
		return -1;
	}

	tmp[eloop.reader_count].sock = sock;
	tmp[eloop.reader_count].eloop_data = eloop_data;
	tmp[eloop.reader_count].user_data = user_data;
	tmp[eloop.reader_count].handler = handler;
	tmp[eloop.reader_count].event = event;
	eloop.reader_count++;
	eloop.readers = tmp;
	if (sock > eloop.max_sock)
		eloop.max_sock = sock;
	eloop.reader_table_changed = 1;

	return 0;
}
开发者ID:174high,项目名称:wpa_supplicant_8_ti,代码行数:41,代码来源:eloop_win.c


示例8: eloop_register_signal

int eloop_register_signal(int sig, eloop_signal_handler handler,
        void *user_data) {
    struct eloop_signal *tmp;

    tmp = (struct eloop_signal *)
            os_realloc(eloop.signals,
            (eloop.signal_count + 1) *
            sizeof (struct eloop_signal));
    if (tmp == NULL)
        return -1;

    tmp[eloop.signal_count].sig = sig;
    tmp[eloop.signal_count].user_data = user_data;
    tmp[eloop.signal_count].handler = handler;
    tmp[eloop.signal_count].signaled = 0;
    eloop.signal_count++;
    eloop.signals = tmp;
    signal(sig, eloop_handle_signal);

    return 0;
}
开发者ID:vk496,项目名称:reaver-wps-fork-t6x,代码行数:21,代码来源:eloop.c


示例9: wpa_config_add_prio_network

/**
 * wpa_config_add_prio_network - Add a network to priority lists
 * @config: Configuration data from wpa_config_read()
 * @ssid: Pointer to the network configuration to be added to the list
 * Returns: 0 on success, -1 on failure
 *
 * This function is used to add a network block to the priority list of
 * networks. This must be called for each network when reading in the full
 * configuration. In addition, this can be used indirectly when updating
 * priorities by calling wpa_config_update_prio_list().
 */
int wpa_config_add_prio_network(struct wpa_config *config,
				struct wpa_ssid *ssid)
{
	int prio;
	struct wpa_ssid *prev, **nlist;

	/*
	 * Add to an existing priority list if one is available for the
	 * configured priority level for this network.
	 */
	for (prio = 0; prio < config->num_prio; prio++) {
		prev = config->pssid[prio];
		if (prev->priority == ssid->priority) {
			while (prev->pnext)
				prev = prev->pnext;
			prev->pnext = ssid;
			return 0;
		}
	}

	/* First network for this priority - add a new priority list */
	nlist = os_realloc(config->pssid,
			   (config->num_prio + 1) * sizeof(struct wpa_ssid *));
	if (nlist == NULL)
		return -1;

	for (prio = 0; prio < config->num_prio; prio++) {
		if (nlist[prio]->priority < ssid->priority)
			break;
	}

	os_memmove(&nlist[prio + 1], &nlist[prio],
		   (config->num_prio - prio) * sizeof(struct wpa_ssid *));

	nlist[prio] = ssid;
	config->num_prio++;
	config->pssid = nlist;

	return 0;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:51,代码来源:config.c


示例10: circle_register_signal

int circle_register_signal(int sig, circle_signal_handler handler,
			  void *user_data)
{
	struct circle_signal *tmp;

	tmp = (struct circle_signal *)
		os_realloc(circle.signals,
			   (circle.signal_count + 1) *
			   sizeof(struct circle_signal));
	if (tmp == NULL)
		return -1;

	tmp[circle.signal_count].sig = sig;
	tmp[circle.signal_count].user_data = user_data;
	tmp[circle.signal_count].handler = handler;
	tmp[circle.signal_count].signaled = 0;
	circle.signal_count++;
	circle.signals = tmp;
	signal(sig, circle_handle_signal);

	return 0;
}
开发者ID:ECYBTech,项目名称:chanos,代码行数:22,代码来源:circle.c


示例11: idl_constExpressionImage

char *
idl_constExpressionImage (
    idl_constExpression constExpression)
{
    char *image = NULL;
    char *operandImage = NULL;
    int i;
    int newLen;

    if (c_iterLength (constExpression->operands) == 1) {
	/* Unary operator */
	operandImage = idl_operandImage (idl_operand(c_iterObject (constExpression->operands, 0)));
	newLen = strlen (operatorImage(constExpression->kind)) + strlen (operandImage) + 3;
	image = os_malloc (newLen);
	snprintf (image, newLen, "(%s%s)", operatorImage(constExpression->kind), operandImage);
	os_free (operandImage);
    } else {
	/* Binary operator */
        for (i = 0; i < c_iterLength (constExpression->operands); i++) {
	    operandImage = idl_operandImage (idl_operand(c_iterObject (constExpression->operands, i)));
	    if (image == NULL) {
	        newLen = strlen (operandImage) + 2;
	        image = os_malloc (newLen);
	       os_strncpy (image, "(", newLen);
	    } else {
	        newLen = strlen (image) + strlen (operatorImage(constExpression->kind)) + strlen (operandImage) + 4;
	        image = os_realloc (image, newLen);
		strncat (image, " ", newLen);
	        os_strncat (image, operatorImage(constExpression->kind), newLen);
		strncat (image, " ", newLen);
	    }
	    os_strncat (image, operandImage, newLen);
	    os_free (operandImage);
        }
	strncat (image, ")", newLen);
    }
    return image;
}
开发者ID:diorahman,项目名称:opensplice,代码行数:38,代码来源:idl_constSpecifier.c


示例12: storage_add_spof_group

int storage_add_spof_group(storage_t *storage, spof_id_t spof_id,
                                  spof_group_t **sg)
{
    uint32_t i;
    spof_group_t *new_spof_groups;

    EXA_ASSERT(storage != NULL);

    EXA_ASSERT(sg != NULL);

    *sg = NULL;

    if (!SPOF_ID_IS_VALID(spof_id))
        return -EINVAL;

    for (i = 0; i < storage->num_spof_groups; i++)
        if (storage->spof_groups[i].spof_id == spof_id)
            return -EEXIST;

    if (storage->num_spof_groups == EXA_MAX_NODES_NUMBER)
        return -ENOSPC;

    new_spof_groups = os_realloc(storage->spof_groups,
            (storage->num_spof_groups + 1) * sizeof(spof_group_t));

    if (new_spof_groups == NULL)
        return -ENOMEM;

    spof_group_init(&new_spof_groups[storage->num_spof_groups]);
    new_spof_groups[storage->num_spof_groups].spof_id = spof_id;

    *sg = &new_spof_groups[storage->num_spof_groups];

    storage->spof_groups = new_spof_groups;
    storage->num_spof_groups++;

    return 0;
}
开发者ID:OznOg,项目名称:OpenExanodes,代码行数:38,代码来源:storage.c


示例13: ap_sa_query_timer

static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
{
	struct hostapd_data *hapd = eloop_ctx;
	struct sta_info *sta = timeout_ctx;
	unsigned int timeout, sec, usec;
	u8 *trans_id, *nbuf;

	if (sta->sa_query_count > 0 &&
	    ap_check_sa_query_timeout(hapd, sta))
		return;

	nbuf = os_realloc(sta->sa_query_trans_id,
			  (sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN);
	if (nbuf == NULL)
		return;
	if (sta->sa_query_count == 0) {
		/* Starting a new SA Query procedure */
		os_get_time(&sta->sa_query_start);
	}
	trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
	sta->sa_query_trans_id = nbuf;
	sta->sa_query_count++;

	os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);

	timeout = hapd->conf->assoc_sa_query_retry_timeout;
	sec = ((timeout / 1000) * 1024) / 1000;
	usec = (timeout % 1000) * 1024;
	eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);

	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
		       HOSTAPD_LEVEL_DEBUG,
		       "association SA Query attempt %d", sta->sa_query_count);

#ifdef NEED_AP_MLME
	ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
#endif /* NEED_AP_MLME */
}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:38,代码来源:sta_info.c


示例14: hostapd_register_probereq_cb

int hostapd_register_probereq_cb(struct hostapd_data *hapd,
				 int (*cb)(void *ctx, const u8 *sa,
					   const u8 *da, const u8 *bssid,
					   const u8 *ie, size_t ie_len,
					   int ssi_signal),
				 void *ctx)
{
	struct hostapd_probereq_cb *n;

	n = os_realloc(hapd->probereq_cb, (hapd->num_probereq_cb + 1) *
		       sizeof(struct hostapd_probereq_cb));
	if (n == NULL)
		return -1;

	hapd->probereq_cb = n;
	n = &hapd->probereq_cb[hapd->num_probereq_cb];
	hapd->num_probereq_cb++;

	n->cb = cb;
	n->ctx = ctx;

	return 0;
}
开发者ID:174high,项目名称:wpa_supplicant_8_ti,代码行数:23,代码来源:utils.c


示例15: dump_syscheck_entry

int dump_syscheck_entry(syscheck_config *syscheck, const char *entry, int vals, int reg, const char *restrictfile)
{
    unsigned int pl = 0;

    if (reg == 1) {
#ifdef WIN32
        if (syscheck->registry == NULL) {
            os_calloc(2, sizeof(registry), syscheck->registry);
            syscheck->registry[pl + 1].entry = NULL;
            syscheck->registry[pl].arch = vals;
            os_strdup(entry, syscheck->registry[pl].entry);
        } else {
            while (syscheck->registry[pl].entry != NULL) {
                pl++;
            }
            os_realloc(syscheck->registry, (pl + 2) * sizeof(registry),
                       syscheck->registry);
            syscheck->registry[pl + 1].entry = NULL;
            syscheck->registry[pl].arch = vals;
            os_strdup(entry, syscheck->registry[pl].entry);
        }

#endif
    }

    else {
        if (syscheck->dir == NULL) {
            os_calloc(2, sizeof(char *), syscheck->dir);
            syscheck->dir[pl + 1] = NULL;
            os_strdup(entry, syscheck->dir[pl]);

            os_calloc(2, sizeof(int), syscheck->opts);
            syscheck->opts[pl + 1] = 0;
            syscheck->opts[pl] = vals;

            os_calloc(2, sizeof(OSMatch *), syscheck->filerestrict);
            syscheck->filerestrict[pl] = NULL;
            syscheck->filerestrict[pl + 1] = NULL;
        } else {
            while (syscheck->dir[pl] != NULL) {
                pl++;
            }
            os_realloc(syscheck->dir, (pl + 2) * sizeof(char *),
                       syscheck->dir);
            syscheck->dir[pl + 1] = NULL;
            os_strdup(entry, syscheck->dir[pl]);

            os_realloc(syscheck->opts, (pl + 2) * sizeof(int),
                       syscheck->opts);
            syscheck->opts[pl + 1] = 0;
            syscheck->opts[pl] = vals;

            os_realloc(syscheck->filerestrict, (pl + 2) * sizeof(OSMatch *),
                       syscheck->filerestrict);
            syscheck->filerestrict[pl] = NULL;
            syscheck->filerestrict[pl + 1] = NULL;
        }
        if (restrictfile) {
            os_calloc(1, sizeof(OSMatch), syscheck->filerestrict[pl]);
            if (!OSMatch_Compile(restrictfile, syscheck->filerestrict[pl], 0)) {
                OSMatch *ptm;

                ptm = syscheck->filerestrict[pl];

                merror(REGEX_COMPILE, __local_name, restrictfile,
                       ptm->error);
                free(syscheck->filerestrict[pl]);
                syscheck->filerestrict[pl] = NULL;
            }
        }
    }

    return (1);
}
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:74,代码来源:syscheck-config.c


示例16: Read_CReports

int Read_CReports(XML_NODE node, void *config, void *config2)
{
    int i = 0,s = 0;

    /* XML definitions */
    char *xml_title = "title";
    char *xml_type = "type";
    char *xml_categories = "category";
    char *xml_group = "group";
    char *xml_rule = "rule";
    char *xml_level = "level";
    char *xml_location = "location";
    char *xml_showlogs = "showlogs";
    char *xml_srcip = "srcip";
    char *xml_user = "user";
    char *xml_frequency = "frequency";
    char *xml_email = "email_to";


    monitor_config *mon_config = (monitor_config *)config;


    /* Getting any configured entry. */
    if(mon_config->reports)
    {
        while(mon_config->reports[s])
            s++;
    }


    /* Allocating the memory for the config. */
    os_realloc(mon_config->reports, (s + 2) * sizeof(report_config *),
               mon_config->reports);
    os_calloc(1, sizeof(report_config), mon_config->reports[s]);
    mon_config->reports[s + 1] = NULL;


    /* Zeroing the elements. */
    mon_config->reports[s]->title = NULL;
    mon_config->reports[s]->args = NULL;
    mon_config->reports[s]->relations = NULL;
    mon_config->reports[s]->type = NULL;
    mon_config->reports[s]->emailto = NULL;

    mon_config->reports[s]->r_filter.group = NULL;
    mon_config->reports[s]->r_filter.rule = NULL;
    mon_config->reports[s]->r_filter.level = NULL;
    mon_config->reports[s]->r_filter.location = NULL;
    mon_config->reports[s]->r_filter.srcip = NULL;
    mon_config->reports[s]->r_filter.user = NULL;
    mon_config->reports[s]->r_filter.related_group = 0;
    mon_config->reports[s]->r_filter.related_rule = 0;
    mon_config->reports[s]->r_filter.related_level = 0;
    mon_config->reports[s]->r_filter.related_location = 0;
    mon_config->reports[s]->r_filter.related_srcip = 0;
    mon_config->reports[s]->r_filter.related_user = 0;
    mon_config->reports[s]->r_filter.report_name = NULL;
    mon_config->reports[s]->r_filter.show_alerts = 0;



    /* Reading the XML. */
    while(node[i])
    {
        if(!node[i]->element)
        {
            merror(XML_ELEMNULL, __local_name);
            return(OS_INVALID);
        }
        else if(!node[i]->content)
        {
            merror(XML_VALUENULL, __local_name, node[i]->element);
            return(OS_INVALID);
        }
        else if(strcmp(node[i]->element, xml_title) == 0)
        {
            if(!mon_config->reports[s]->title)
            {
                os_strdup(node[i]->content, mon_config->reports[s]->title);
            }
        }
        else if(strcmp(node[i]->element, xml_type) == 0)
        {
            if(strcmp(node[i]->content, "email") == 0)
            {
                if(!mon_config->reports[s]->type)
                {
                    os_strdup(node[i]->content, mon_config->reports[s]->type);
                }
            }
            else
            {
                merror(XML_VALUEERR, __local_name,node[i]->element,node[i]->content);
            }
        }
        else if(strcmp(node[i]->element, xml_frequency) == 0)
        {
        }
        else if(strcmp(node[i]->element, xml_showlogs) == 0)
        {
//.........这里部分代码省略.........
开发者ID:RobertoD91,项目名称:ossec,代码行数:101,代码来源:reports-config.c


示例17: eap_tls_data_reassemble

const u8 * eap_tls_data_reassemble(
	struct eap_sm *sm, struct eap_ssl_data *data, const u8 *in_data,
	size_t in_len, size_t *out_len, int *need_more_input)
{
	u8 *buf;

	*need_more_input = 0;

	if (data->tls_in_left > in_len || data->tls_in) {
		if (data->tls_in_len + in_len == 0) {
			os_free(data->tls_in);
			data->tls_in = NULL;
			data->tls_in_len = 0;
			wpa_printf(MSG_WARNING, "SSL: Invalid reassembly "
				   "state: tls_in_left=%lu tls_in_len=%lu "
				   "in_len=%lu",
				   (unsigned long) data->tls_in_left,
				   (unsigned long) data->tls_in_len,
				   (unsigned long) in_len);
			return NULL;
		}
		if (data->tls_in_len + in_len > 65536) {
			/* Limit length to avoid rogue servers from causing
			 * large memory allocations. */
			os_free(data->tls_in);
			data->tls_in = NULL;
			data->tls_in_len = 0;
			wpa_printf(MSG_INFO, "SSL: Too long TLS fragment (size"
				   " over 64 kB)");
			return NULL;
		}
		buf = os_realloc(data->tls_in, data->tls_in_len + in_len);
		if (buf == NULL) {
			os_free(data->tls_in);
			data->tls_in = NULL;
			data->tls_in_len = 0;
			wpa_printf(MSG_INFO, "SSL: Could not allocate memory "
				   "for TLS data");
			return NULL;
		}
		os_memcpy(buf + data->tls_in_len, in_data, in_len);
		data->tls_in = buf;
		data->tls_in_len += in_len;
		if (in_len > data->tls_in_left) {
			wpa_printf(MSG_INFO, "SSL: more data than TLS message "
				   "length indicated");
			data->tls_in_left = 0;
			return NULL;
		}
		data->tls_in_left -= in_len;
		if (data->tls_in_left > 0) {
			wpa_printf(MSG_DEBUG, "SSL: Need %lu bytes more input "
				   "data", (unsigned long) data->tls_in_left);
			*need_more_input = 1;
			return NULL;
		}
	} else {
		data->tls_in_left = 0;
		data->tls_in = os_malloc(in_len ? in_len : 1);
		if (data->tls_in == NULL)
			return NULL;
		os_memcpy(data->tls_in, in_data, in_len);
		data->tls_in_len = in_len;
	}

	*out_len = data->tls_in_len;
	return data->tls_in;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:68,代码来源:eap_tls_common.c


示例18: eap_peer_select_phase2_methods

/**
 * eap_peer_select_phase2_methods - Select phase 2 EAP method
 * @config: Pointer to the network configuration
 * @prefix: 'phase2' configuration prefix, e.g., "auth="
 * @types: Buffer for returning allocated list of allowed EAP methods
 * @num_types: Buffer for returning number of allocated EAP methods
 * Returns: 0 on success, -1 on failure
 *
 * This function is used to parse EAP method list and select allowed methods
 * for Phase2 authentication.
 */
int eap_peer_select_phase2_methods(struct eap_peer_config *config,
				   const char *prefix,
				   struct eap_method_type **types,
				   size_t *num_types)
{
	char *start, *pos, *buf;
	struct eap_method_type *methods = NULL, *_methods;
	u8 method;
	size_t num_methods = 0, prefix_len;

	if (config == NULL || config->phase2 == NULL)
		goto get_defaults;

	start = buf = os_strdup(config->phase2);
	if (buf == NULL)
		return -1;

	prefix_len = os_strlen(prefix);

	while (start && *start != '\0') {
		int vendor;
		pos = os_strstr(start, prefix);
		if (pos == NULL)
			break;
		if (start != pos && *(pos - 1) != ' ') {
			start = pos + prefix_len;
			continue;
		}

		start = pos + prefix_len;
		pos = os_strchr(start, ' ');
		if (pos)
			*pos++ = '\0';
		method = eap_get_phase2_type(start, &vendor);
		if (vendor == EAP_VENDOR_IETF && method == EAP_TYPE_NONE) {
			wpa_printf(MSG_ERROR, "TLS: Unsupported Phase2 EAP "
				   "method '%s'", start);
		} else {
			num_methods++;
			_methods = os_realloc(methods,
					      num_methods * sizeof(*methods));
			if (_methods == NULL) {
				os_free(methods);
				os_free(buf);
				return -1;
			}
			methods = _methods;
			methods[num_methods - 1].vendor = vendor;
			methods[num_methods - 1].method = method;
		}

		start = pos;
	}

	os_free(buf);

get_defaults:
	if (methods == NULL)
		methods = eap_get_phase2_types(config, &num_methods);

	if (methods == NULL) {
		wpa_printf(MSG_ERROR, "TLS: No Phase2 EAP methods available");
		return -1;
	}
	wpa_hexdump(MSG_DEBUG, "TLS: Phase2 EAP types",
		    (u8 *) methods,
		    num_methods * sizeof(struct eap_method_type));

	*types = methods;
	*num_types = num_methods;

	return 0;
}
开发者ID:Austrie,项目名称:android_external_hostapd,代码行数:84,代码来源:eap_tls_common.c


示例19: wpa_config_parse_eap

static int wpa_config_parse_eap(const struct parse_data *data,
				struct wpa_ssid *ssid, int line,
				const char *value)
{
	int last, errors = 0;
	char *start, *end, *buf;
	struct eap_method_type *methods = NULL, *tmp;
	size_t num_methods = 0;

	buf = os_strdup(value);
	if (buf == NULL)
		return -1;
	start = buf;

	while (*start != '\0') {
		while (*start == ' ' || *start == '\t')
			start++;
		if (*start == '\0')
			break;
		end = start;
		while (*end != ' ' && *end != '\t' && *end != '\0')
			end++;
		last = *end == '\0';
		*end = '\0';
		tmp = methods;
		methods = os_realloc(methods,
				     (num_methods + 1) * sizeof(*methods));
		if (methods == NULL) {
			os_free(tmp);
			os_free(buf);
			return -1;
		}
		methods[num_methods].method = eap_peer_get_type(
			start, &methods[num_methods].vendor);
		if (methods[num_methods].vendor == EAP_VENDOR_IETF &&
		    methods[num_methods].method == EAP_TYPE_NONE) {
			wpa_printf(MSG_ERROR, "Line %d: unknown EAP method "
				   "'%s'", line, start);
			wpa_printf(MSG_ERROR, "You may need to add support for"
				   " this EAP method during wpa_supplicant\n"
				   "build time configuration.\n"
				   "See README for more information.");
			errors++;
		} else if (methods[num_methods].vendor == EAP_VENDOR_IETF &&
			   methods[num_methods].method == EAP_TYPE_LEAP)
			ssid->leap++;
		else
			ssid->non_leap++;
		num_methods++;
		if (last)
			break;
		start = end + 1;
	}
	os_free(buf);

	tmp = methods;
	methods = os_realloc(methods, (num_methods + 1) * sizeof(*methods));
	if (methods == NULL) {
		os_free(tmp);
		return -1;
	}
	methods[num_methods].vendor = EAP_VENDOR_IETF;
	methods[num_methods].method = EAP_TYPE_NONE;
	num_methods++;

	wpa_hexdump(MSG_MSGDUMP, "eap methods",
		    (u8 *) methods, num_methods * sizeof(*methods));
	ssid->eap.eap_methods = methods;
	return errors ? -1 : 0;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:70,代码来源:config.c


示例20: Read_Syscheck


//.........这里部分代码省略.........
            int ign_size = 0;

            /* For Windows, we attempt to expand environment variables. */
            #ifdef WIN32
            char *new_ig = NULL;
            os_calloc(2048, sizeof(char), new_ig);

            ExpandEnvironmentStrings(node[i]->content, new_ig, 2047);

            free(node[i]->content);
            node[i]->content = new_ig;
            #endif

            /* Adding if regex */
            if(node[i]->attributes && node[i]->values)
            {
                if(node[i]->attributes[0] && node[i]->values[0] &&
                   (strcmp(node[i]->attributes[0], "type") == 0) &&
                   (strcmp(node[i]->values[0], "sregex") == 0))
                {
                    OSMatch *mt_pt;

                    if(!syscheck->ignore_regex)
                    {
                        os_calloc(2, sizeof(OSMatch *),syscheck->ignore_regex);
                        syscheck->ignore_regex[0] = NULL;
                        syscheck->ignore_regex[1] = NULL;
                    }
                    else
                    {
                        while(syscheck->ignore_regex[ign_size] != NULL)
                            ign_size++;

                        os_realloc(syscheck->ignore_regex,
                                sizeof(OSMatch *)*(ign_size +2),
                                syscheck->ignore_regex);
                        syscheck->ignore_regex[ign_size +1] = NULL;
                    }
                    os_calloc(1, sizeof(OSMatch),
                            syscheck->ignore_regex[ign_size]);

                    if(!OSMatch_Compile(node[i]->content,
                                        syscheck->ignore_regex[ign_size], 0))
                    {
                        mt_pt = (OSMatch *)syscheck->ignore_regex[ign_size];
                        merror(REGEX_COMPILE, ARGV0, node[i]->content,
                              mt_pt->error);
                        return(0);
                    }
                }
                else
                {
                    merror(SK_INV_ATTR, ARGV0, node[i]->attributes[0]);
                    return(OS_INVALID);
                }
            }

            /* Adding if simple entry -- checking for duplicates */
            else if(!os_IsStrOnArray(node[i]->content, syscheck->ignore))
            {
                if(!syscheck->ignore)
                {
                    os_calloc(2, sizeof(char *), syscheck->ignore);
                    syscheck->ignore[0] = NULL;
                    syscheck->ignore[1] = NULL;
                }
开发者ID:RobertoD91,项目名称:ossec,代码行数:67,代码来源:syscheck-config.c



注:本文中的os_realloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ os_realloc_array函数代码示例发布时间:2022-05-30
下一篇:
C++ os_program_init函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap