diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cac.c | 2 | ||||
-rw-r--r-- | src/card_7816.c | 2 | ||||
-rw-r--r-- | src/common.h | 6 | ||||
-rw-r--r-- | src/simpletlv.c | 4 | ||||
-rw-r--r-- | src/vcard.c | 5 | ||||
-rw-r--r-- | src/vcard_emul_nss.c | 5 | ||||
-rw-r--r-- | src/vscclient.c | 2 |
7 files changed, 17 insertions, 9 deletions
@@ -1972,7 +1972,7 @@ cac_new_empty_applet_private(unsigned char objects[][2], unsigned int objects_le /* Create Object ID list */ if (objects_len > 0) { - applet_private->coids = g_memdup(objects, sizeof(struct coid) * objects_len); + applet_private->coids = g_memdup2(objects, sizeof(struct coid) * objects_len); applet_private->coids_len = objects_len; } diff --git a/src/card_7816.c b/src/card_7816.c index bf481f0..9cb77e5 100644 --- a/src/card_7816.c +++ b/src/card_7816.c @@ -352,7 +352,7 @@ vcard_apdu_new(unsigned char *raw_apdu, int len, vcard_7816_status_t *status) } new_apdu = g_new(VCardAPDU, 1); - new_apdu->a_data = g_memdup(raw_apdu, len); + new_apdu->a_data = g_memdup2(raw_apdu, len); new_apdu->a_len = len; *status = vcard_apdu_set_class(new_apdu); if (*status != VCARD7816_STATUS_SUCCESS) { diff --git a/src/common.h b/src/common.h index 5210367..d513edc 100644 --- a/src/common.h +++ b/src/common.h @@ -26,9 +26,15 @@ #include <stddef.h> +#include "config.h" + unsigned char *ushort2lebytes(unsigned char *buf, unsigned short x); unsigned short lebytes2ushort(const unsigned char *buf); char *hex_dump(const unsigned char *buf, size_t buflen); +#ifndef HAVE_G_MEMDUP2 +#define g_memdup2(ptr,sz) ((G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(), NULL)) +#endif + #endif diff --git a/src/simpletlv.c b/src/simpletlv.c index c0e38a0..bc2b91d 100644 --- a/src/simpletlv.c +++ b/src/simpletlv.c @@ -292,7 +292,7 @@ simpletlv_clone(struct simpletlv_member *tlv, size_t tlvlen) if (new[i].value.child == NULL) goto failure; } else { - new[i].value.value = g_memdup(tlv[i].value.value, tlv[i].length); + new[i].value.value = g_memdup2(tlv[i].value.value, tlv[i].length); } } return new; @@ -332,7 +332,7 @@ simpletlv_parse(unsigned char *data, size_t data_len, size_t *outtlv_len) tlvp.tag = tag; tlvp.length = vlen; - tlvp.value.value = g_memdup(p, vlen); + tlvp.value.value = g_memdup2(p, vlen); tlvp.type = SIMPLETLV_TYPE_LEAF; g_array_append_val(tlv, tlvp); diff --git a/src/vcard.c b/src/vcard.c index 9a87575..fda6cd1 100644 --- a/src/vcard.c +++ b/src/vcard.c @@ -12,6 +12,7 @@ #include "vcard.h" #include "vcard_emul.h" #include "card_7816t.h" +#include "common.h" struct VCardAppletStruct { VCardApplet *next; @@ -43,7 +44,7 @@ vcard_buffer_response_new(const unsigned char *buffer, int size) VCardBufferResponse *new_buffer; new_buffer = g_new(VCardBufferResponse, 1); - new_buffer->buffer = (unsigned char *)g_memdup(buffer, size); + new_buffer->buffer = (unsigned char *)g_memdup2(buffer, size); new_buffer->buffer_len = size; new_buffer->current = new_buffer->buffer; new_buffer->len = size; @@ -108,7 +109,7 @@ vcard_new_applet(VCardProcessAPDU applet_process_function, applet->process_apdu = applet_process_function; applet->reset_applet = applet_reset_function; - applet->aid = g_memdup(aid, aid_len); + applet->aid = g_memdup2(aid, aid_len); applet->aid_len = aid_len; return applet; } diff --git a/src/vcard_emul_nss.c b/src/vcard_emul_nss.c index 1f922c5..289a60a 100644 --- a/src/vcard_emul_nss.c +++ b/src/vcard_emul_nss.c @@ -9,10 +9,11 @@ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING file in the top-level directory. */ -#include "config.h" #include <glib.h> +#include "common.h" + /* * NSS headers */ @@ -1470,7 +1471,7 @@ vcard_emul_read_object(VCard *card, const char *label, return NULL; *ret_len = result.len; - ret = g_memdup(result.data, result.len); + ret = g_memdup2(result.data, result.len); PORT_Free(result.data); return ret; } diff --git a/src/vscclient.c b/src/vscclient.c index 5d1efc2..98cb39a 100644 --- a/src/vscclient.c +++ b/src/vscclient.c @@ -466,7 +466,7 @@ do_socket_read(GIOChannel *source, #if defined(ENABLE_PCSC) if (with_pcsc) { reply_size = dwRecvLength; - reply = g_memdup(pbRecvBuffer, reply_size); + reply = g_memdup2(pbRecvBuffer, reply_size); dwSendLength = mhHeader.length; dwRecvLength = sizeof(pbRecvBuffer); |