return (0);
}
- entry = ep_alloc (sizeof (*entry));
- if (entry == NULL)
- return (-1);
- memset (entry, 0, sizeof (*entry));
-
+ entry = ep_alloc0 (sizeof (*entry));
entry->string = ep_strdup (new_value);
- if (entry->string == NULL)
- return (-1);
entry->count = 1;
entry->next = *ret_list;
wep_keylens[keyidx] = 0;
#ifdef USE_ENV
- buf=ep_alloc(128);
- g_snprintf(buf, 128, "WIRESHARK_WEPKEY%d", i+1);
+ buf = ep_strdup_printf("WIRESHARK_WEPKEY%d", i+1);
tmp = getenv(buf);
#else
tmp = wep_keystr[i];
keys. So just give it a copy of the crypto data instead.
This has been seen for RC4-HMAC blobs.
*/
- cryptocopy=g_malloc(length);
- memcpy(cryptocopy, cryptotext, length);
+ cryptocopy=g_memdup(cryptotext, length);
ret = krb5_decrypt_ivec(krb5_ctx, crypto, usage,
cryptocopy, length,
&data,
proto_tree_add_text(tree, NULL, 0, 0, "[Decrypted using: %s]", ek->key_origin);
krb5_crypto_destroy(krb5_ctx, crypto);
/* return a private g_malloced blob to the caller */
- user_data=g_malloc(data.length);
- memcpy(user_data, data.data, data.length);
+ user_data=g_memdup(data.data, data.length);
if (datalen) {
*datalen = data.length;
}
new_key->kvno = 0;
new_key->keytype = keytype;
new_key->length = keylength;
- new_key->contents = g_malloc(keylength);
- memcpy(new_key->contents, keyvalue, keylength);
+ new_key->contents = g_memdup(keyvalue, keylength);
g_snprintf(new_key->origin, KRB_MAX_ORIG_LEN, "%s learnt from frame %u", origin, pinfo->fd->num);
service_key_list = g_slist_append(service_key_list, (gpointer) new_key);
}
sk->kvno = buf[0] << 8 | buf[1];
sk->keytype = KEYTYPE_DES3_CBC_MD5;
sk->length = DES3_KEY_SIZE;
- sk->contents = g_malloc(DES3_KEY_SIZE);
- memcpy(sk->contents, buf + 2, DES3_KEY_SIZE);
+ sk->contents = g_memdup(buf + 2, DES3_KEY_SIZE);
g_snprintf(sk->origin, KRB_MAX_ORIG_LEN, "3DES service key file, key #%d, offset %ld", count, ftell(skf));
service_key_list = g_slist_append(service_key_list, (gpointer) sk);
fseek(skf, newline_skip, SEEK_CUR);
}
if (string_data) {
- char *tmpstr;
- tmpstr = tvb_get_ephemeral_string(tvb, data_offset, string_length_copy);
- string_buffer = memcpy(ep_alloc(string_length_copy+1), tmpstr, string_length_copy);
+ string_buffer = tvb_get_ephemeral_string(tvb, data_offset, string_length_copy);
} else {
string_buffer = tvb_memcpy(tvb, ep_alloc(string_length_copy+1), data_offset, string_length_copy);
}
{ 0,NULL,NULL,NULL }
};
- NAME=g_malloc(36);
- Name=g_malloc(32);
- name=g_malloc(32);
- g_snprintf(NAME, 36, "Unknown RPC Program:%d",prpc_prog_key->prog);
- g_snprintf(Name, 32, "RPC:%d",prpc_prog_key->prog);
- g_snprintf(name, 32, "rpc%d",prpc_prog_key->prog);
+ NAME = g_strdup_printf("Unknown RPC Program:%d",prpc_prog_key->prog);
+ Name = g_strdup_printf("RPC:%d",prpc_prog_key->prog);
+ name = g_strdup_printf("rpc%d",prpc_prog_key->prog);
proto_rpc_unknown_program = proto_register_protocol(NAME, Name, name);
rpc_init_prog(proto_rpc_unknown_program, prpc_prog_key->prog, ett_rpc_unknown_program);
#define UDP_PORT_TPNCP_HOST BASE_TPNCP_PORT
#define BASE_TPNCP_DATA_LEN 256
-#define MAX_TPNCP_DAT_FILE_PATH_LEN BASE_TPNCP_DATA_LEN
#define MAX_TPNCP_DB_ENTRY_LEN BASE_TPNCP_DATA_LEN
#define MAX_TPNCP_DB_SIZE 3000
/*-------------------------------------------------------------------------------------------------------------------------------------------*/
static gint init_tpncp_db(void) {
- gchar *tpncp_dat_file_path = NULL;
- FILE *file = NULL;
+ gchar *tpncp_dat_file_path;
+ FILE *file;
- tpncp_dat_file_path = ep_alloc(MAX_TPNCP_DAT_FILE_PATH_LEN);
- tpncp_dat_file_path[0] = 0;
- g_snprintf(tpncp_dat_file_path, MAX_TPNCP_DAT_FILE_PATH_LEN, "%s" G_DIR_SEPARATOR_S"tpncp" G_DIR_SEPARATOR_S "tpncp.dat", get_datafile_dir());
+ tpncp_dat_file_path = ep_strdup_printf("%s" G_DIR_SEPARATOR_S"tpncp" G_DIR_SEPARATOR_S "tpncp.dat", get_datafile_dir());
/* Open file with TPNCP data. */
if ((file = ws_fopen(tpncp_dat_file_path, "r")) == NULL)
static slcompress *
slhc_init(void)
{
- slcompress *comp = se_alloc(sizeof(slcompress));
+ slcompress *comp = se_alloc0(sizeof(slcompress));
int i;
- memset(comp, ZERO, sizeof(slcompress));
-
/*
* Initialize the state; there is no current connection, and
* we have no header data for any of the connections, as we