From 9696d9dae8781da20edd3e8e6d592c42dc66c4da Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 27 Oct 2005 08:50:42 +0000 Subject: remove a strcpy make the code A LOT nicer and get rid of unchecked memcpy svn path=/trunk/; revision=16332 --- epan/dissectors/packet-ldap.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 60430258e8..307dc5e281 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -661,19 +661,9 @@ static int parse_filter_strings(ASN1_SCK *a, char **filter, guint *filter_length *filter_length += 2 + strlen(operation) + string_length + string2_length; *filter = g_realloc(*filter, *filter_length); filterp = *filter + strlen(*filter); - *filterp++ = '('; - if (string_length != 0) { - memcpy(filterp, string, string_length); - filterp += string_length; - } - strcpy(filterp, operation); - filterp += strlen(operation); - if (string2_length != 0) { - memcpy(filterp, string2, string2_length); - filterp += string2_length; - } - *filterp++ = ')'; - *filterp = '\0'; + + filterp += g_snprintf(filterp, (*filter_length)-(filterp-*filter), "(%s%s%s)", string, operation, string2); + g_free(string); g_free(string2); return ASN1_ERR_NOERROR; -- cgit v1.2.3