Hello Dan,

Can you tell me what bug the first patch fixes.  In my opinion,
the second memcpy() changed is not necessary and harmless.
The changed code, in my opinion, is a bad construct.  Is sizeof(*ctx)
really properly defined when ctx is a struct.  It would be *far* better
to change it to sizeof(struct MD5Context).  Even then, I don't
really see the purpose of zeroing out the structure except perhaps
for security reasons.

The second patch that removes code, should not be removed as
it will remove code that is used by some plugins and expose
them to improperly allocated memory. It is true that it
is not particularly (in general) a good idea to clear out memory
allocated by new.  However, in Bacula our C++ constructs permit
doing so.

Best regards,
Kern

On 11/06/2013 11:21 PM, Dan Langille wrote:
> I was contacted on IRC by jo...@netbsd.org with a couple of patches which 
> originate from NetBSD.
>
> Please address all questions to the patch writer, ccd on this post.
>
> I’ve pasted the patches and included a link to the raw patch.
>
> This patch fixes a bug:
>
> http://www.netbsd.org/~joerg/patch-src_lib_md5.c
>
> $NetBSD$
>
> --- src/lib/md5.c.orig        2013-11-06 15:37:34.000000000 +0000
> +++ src/lib/md5.c
> @@ -173,7 +173,7 @@ void MD5Final(unsigned char digest[16], 
>      MD5Transform(ctx->buf, (uint32_t *) ctx->in);
>      byteReverse((unsigned char *) ctx->buf, 4);
>      memcpy(digest, ctx->buf, 16);
> -    memset(ctx, 0, sizeof(ctx));        /* In case it's sensitive */
> +    memset(ctx, 0, sizeof(*ctx));        /* In case it's sensitive */
>  }
>
>
> This patch removes code used only by test-* something, and it breaks with 
> modern clang.  The claim is it is buggy in general, and the default behavior 
> of new/delete is to not fai.
>
> http://www.netbsd.org/~joerg/patch-src_plugins_fd_fd__common.h
>
> $NetBSD$
>
> --- src/plugins/fd/fd_common.h.orig   2013-11-06 15:38:19.000000000 +0000
> +++ src/plugins/fd/fd_common.h
> @@ -71,46 +71,6 @@ DLL_IMP_EXP void reallyfree(const char *
>  #define malloc(s)    sm_malloc(__FILE__, __LINE__, (s))
>  #define free(o)      sm_free(__FILE__, __LINE__, (o))
>  
> -inline void *operator new(size_t size, char const * file, int line)
> -{
> -   void *pnew = sm_malloc(file,line, size);
> -   memset((char *)pnew, 0, size);
> -   return pnew;
> -}
> -
> -inline void *operator new[](size_t size, char const * file, int line)
> -{
> -   void *pnew = sm_malloc(file, line, size);
> -   memset((char *)pnew, 0, size);
> -   return pnew;
> -}
> -
> -inline void *operator new(size_t size)
> -{
> -   void *pnew = sm_malloc(__FILE__, __LINE__, size);
> -   memset((char *)pnew, 0, size);
> -   return pnew;
> -}
> -
> -inline void *operator new[](size_t size)
> -{
> -   void *pnew = sm_malloc(__FILE__, __LINE__, size);
> -   memset((char *)pnew, 0, size);
> -   return pnew;
> -}
> -
> -#define new   new(__FILE__, __LINE__)
> -
> -inline void operator delete(void *buf)
> -{
> -   sm_free( __FILE__, __LINE__, buf);
> -}
> -
> -inline void operator delete[] (void *buf)
> -{
> -  sm_free(__FILE__, __LINE__, buf);
> -}
> -
>  #define Dmsg(context, level,  ...) bfuncs->DebugMessage(context, __FILE__, 
> __LINE__, level, __VA_ARGS__ )
>  #define Jmsg(context, type,  ...) bfuncs->JobMessage(context, __FILE__, 
> __LINE__, type, 0, __VA_ARGS__ )
>  
>


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to