[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-internals
Subject:    [PATCH] Adjust memset() call in mysys/md5.c
From:       Art Haas <ahaas () impactweather ! com>
Date:       2011-07-17 13:32:52
Message-ID: tqg39i5rq0r.fsf () impactweather ! com
[Download RAW message or body]


Hi.

I tried out 'clang' to build MySQL, and a warning about the memset()
call on line 179 showed up with a suggested correction of dereferencing
'ctx' in the sizeof() call. A look at the code and I think that
the 'clang' compiler suggestion is valid as the memset() call is
only adjusting a pointer-sized number of bytes in the 'ctx' structure
instead of clearing the entire thing, plus the change makes the
code match the intention of the comment.

My build was the 'mysql-trunk', but a quick look at the 'mysql-5.5'
branch and few of the 'mysql-server/cluster' branches shows the
patch could also be applied there as well.

Art Haas

=== modified file 'mysys/md5.c'
--- mysys/md5.c 2009-03-09 18:57:03 +0000
+++ mysys/md5.c 2011-07-17 12:54:31 +0000
@@ -176,7 +176,7 @@
   putu32(ctx->buf[1], digest + 4);
   putu32(ctx->buf[2], digest + 8);
   putu32(ctx->buf[3], digest + 12);
-  memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+  memset(ctx, 0, sizeof(*ctx));        /* In case it's sensitive */
 }

 #ifndef ASM_MD5


-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals?unsub=mysql-internals@progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic