aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2010-02-04 06:42:04 +0000
committerAnders Broman <anders.broman@ericsson.com>2010-02-04 06:42:04 +0000
commit8c07e341236075470b55cd2adcff90c4c43e0a41 (patch)
treeee9018f377048ceed609c70d00fe9fdf4f2ded73 /epan
parentc959c3ffa3cf418bf852f4418a53c9c6153117a5 (diff)
Reversion of SVN 30488 as suggested in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4450.
"g_strlcpy() assumes that src *IS* ASCII NUL terminated. If the src buffer is not NUL terminated, g_strlcpy() *WILL* read past the end of the buffer." svn path=/trunk/; revision=31782
Diffstat (limited to 'epan')
-rw-r--r--epan/emem.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/epan/emem.c b/epan/emem.c
index 77e9e97743..ab77569d87 100644
--- a/epan/emem.c
+++ b/epan/emem.c
@@ -839,8 +839,12 @@ gchar *
ep_strndup(const gchar* src, size_t len)
{
gchar* dst = ep_alloc(len+1);
+ guint i;
+
+ for (i = 0; (i < len) && src[i]; i++)
+ dst[i] = src[i];
- g_strlcpy(dst, src, len+1);
+ dst[i] = '\0';
return dst;
}
@@ -988,8 +992,12 @@ gchar *
se_strndup(const gchar* src, size_t len)
{
gchar* dst = se_alloc(len+1);
+ guint i;
+
+ for (i = 0; (i < len) && src[i]; i++)
+ dst[i] = src[i];
- g_strlcpy(dst, src, len+1);
+ dst[i] = '\0';
return dst;
}