summaryrefslogtreecommitdiff
path: root/strings/my_vsnprintf.c
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.(none)>2006-05-02 13:42:35 -0400
committerunknown <cmiller@zippy.(none)>2006-05-02 13:42:35 -0400
commit28d799f1009b50d739e62c43565ecb2cea97450c (patch)
tree45ad457365ca4cdddd8d8818d0c7c238e2dd4fd4 /strings/my_vsnprintf.c
parent4d1cd02ef6fb976b12b0ee9542f49ababc81abeb (diff)
downloadmariadb-git-28d799f1009b50d739e62c43565ecb2cea97450c.tar.gz
An update to as-yet unused new feature of snprintf, which was added to bring
our sprintf()-alike in sync with our fprintf()-alike features. strings/my_vsnprintf.c: Advance the destination pointer properly. Also, pay attention to the "n" in snprintf() -- never write too much.
Diffstat (limited to 'strings/my_vsnprintf.c')
-rw-r--r--strings/my_vsnprintf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index d917e9e11b2..e4302f50c58 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -99,7 +99,11 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
else if (*fmt == 'b') /* Buffer parameter */
{
char *par = va_arg(ap, char *);
- to=memmove(to, par, abs(width));
+ DBUG_ASSERT(to <= end);
+ if (to + abs(width) + 1 > end)
+ width= end - to - 1; /* sign doesn't matter */
+ memmove(to, par, abs(width));
+ to+= width;
continue;
}
else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x') /* Integer parameter */