tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: SHA384_Update symbol clash with libgs



> I think that it was already addressed upstream (at least by inspecting
> ghostscript-agpl ${WRKSRC}/doc/History9.htm):
So, how strange can this get?

1. They prefixed the functions with "p" for "private", which is not an
   especially unique prefix.

2. They aparently already prefixed the SHA256 with "p" before.

3. They DON'T ACTUALLY USE the 384/512 variants anywhere. They could as
   well have simply deleted them.

Sigh.

Could someone commit something like the attached patch, please?
Shall I file a PR instead?
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/print/ghostscript-gpl/distinfo,v
retrieving revision 1.22
diff -u -r1.22 distinfo
--- distinfo	13 Nov 2017 16:52:51 -0000	1.22
+++ distinfo	8 Apr 2019 17:33:21 -0000
@@ -28,6 +28,8 @@
 SHA1 (patch-base_gserrors_h) = fde64bd096a6e6f94005c8352a6295df06c19bae
 SHA1 (patch-base_gsmalloc.c) = 891bdcef49e0f2c435744eaf7bbcd31f5dbcbaba
 SHA1 (patch-base_memento.c) = d30cfb9285a0268e743c90cdf831674eaa24789b
+SHA1 (patch-base_sha2.c) = aeec3e52091d2105dd768352190a307c68d9a39d
+SHA1 (patch-base_sha2.h) = a2a8be6a536f6a3d2f529834862ecdf53d9606d2
 SHA1 (patch-cups_colord.h) = ab5c4bfa7184d2c1756697b87e7046645bdc2bc2
 SHA1 (patch-openjpeg_libopenjpeg_opj_malloc_h) = 24f15c55cd7961afc1254f6c4bccd6d0c2a5e737
 SHA1 (patch-psi_zfile.c) = 24626fed9b161a77d9ab43233bad4c8391120b16
Index: patches/patch-base_sha2.c
===================================================================
RCS file: patches/patch-base_sha2.c
diff -N patches/patch-base_sha2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-base_sha2.c	8 Apr 2019 17:33:21 -0000
@@ -0,0 +1,111 @@
+$NetBSD: patch-base_sha2.h $
+Avoid symbol clash with libc's SHA{384,512}_Xxxx functions by prepending a `p'
+ to them.
+One could actually as well delete them as they aren't actually used anywhere.
+See Ghostscript Bug 694766 (https://bugs.ghostscript.com/show_bug.cgi?id=694766)
+and the patch in there
+(http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=48a0dd97).
+
+--- base/sha2.h.orig
++++ base/sha2.h
+@@ -118,40 +118,40 @@ typedef SHA512_CTX SHA384_CTX;
+ void pSHA256_Init(SHA256_CTX *);
+ void pSHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
+ void pSHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
+-char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
+-char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
++char* pSHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
++char* pSHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
+ 
+-void SHA384_Init(SHA384_CTX*);
+-void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
+-void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
+-char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
+-char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
++void pSHA384_Init(SHA384_CTX*);
++void pSHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
++void pSHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
++char* pSHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
++char* pSHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
+ 
+-void SHA512_Init(SHA512_CTX*);
+-void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
+-void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
+-char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
+-char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
++void pSHA512_Init(SHA512_CTX*);
++void pSHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
++void pSHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
++char* pSHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
++char* pSHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
+ 
+ #else /* SHA2_USE_INTTYPES_H */
+ 
+ void pSHA256_Init(SHA256_CTX *);
+ void pSHA256_Update(SHA256_CTX*, const u_int8_t*, size_t);
+ void pSHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
+-char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
+-char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
++char* pSHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
++char* pSHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
+ 
+-void SHA384_Init(SHA384_CTX*);
+-void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t);
+-void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
+-char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
+-char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
++void pSHA384_Init(SHA384_CTX*);
++void pSHA384_Update(SHA384_CTX*, const u_int8_t*, size_t);
++void pSHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
++char* pSHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
++char* pSHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
+ 
+-void SHA512_Init(SHA512_CTX*);
+-void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t);
+-void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
+-char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
+-char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
++void pSHA512_Init(SHA512_CTX*);
++void pSHA512_Update(SHA512_CTX*, const u_int8_t*, size_t);
++void pSHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
++char* pSHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
++char* pSHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
+ 
+ #endif /* SHA2_USE_INTTYPES_H */
+ 
+@@ -160,20 +160,20 @@ char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
+ void pSHA256_Init();
+ void pSHA256_Update();
+ void pSHA256_Final();
+-char* SHA256_End();
+-char* SHA256_Data();
+-
+-void SHA384_Init();
+-void SHA384_Update();
+-void SHA384_Final();
+-char* SHA384_End();
+-char* SHA384_Data();
+-
+-void SHA512_Init();
+-void SHA512_Update();
+-void SHA512_Final();
+-char* SHA512_End();
+-char* SHA512_Data();
++char* pSHA256_End();
++char* pSHA256_Data();
++
++void pSHA384_Init();
++void pSHA384_Update();
++void pSHA384_Final();
++char* pSHA384_End();
++char* pSHA384_Data();
++
++void pSHA512_Init();
++void pSHA512_Update();
++void pSHA512_Final();
++char* pSHA512_End();
++char* pSHA512_Data();
+ 
+ #endif /* NOPROTO */
+ 
+
Index: patches/patch-base_sha2.h
===================================================================
RCS file: patches/patch-base_sha2.h
diff -N patches/patch-base_sha2.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-base_sha2.h	8 Apr 2019 17:33:21 -0000
@@ -0,0 +1,181 @@
+$NetBSD: patch-base_sha2.h $
+Avoid symbol clash with libc's SHA{384,512}_Xxxx functions by prepending a `p'
+ to them.
+One could actually as well delete them as they aren't actually used anywhere.
+See Ghostscript Bug 694766 (https://bugs.ghostscript.com/show_bug.cgi?id=694766)
+and the patch in there
+(http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=48a0dd97).
+
+--- base/sha2.c.orig
++++ base/sha2.c
+@@ -240,7 +240,7 @@ typedef u_int64_t sha2_word64;	/* Exactly 8 bytes */
+  * library -- they are intended for private internal visibility/use
+  * only.
+  */
+-void SHA512_Last(SHA512_CTX*);
++void pSHA512_Last(SHA512_CTX*);
+ void pSHA256_Transform(SHA256_CTX*, const sha2_word32*);
+ void pSHA512_Transform(SHA512_CTX*, const sha2_word64*);
+ 
+@@ -646,7 +646,7 @@ void pSHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+         usedspace = 0;
+ }
+ 
+-char *SHA256_End(SHA256_CTX* context, char buffer[]) {
++char *pSHA256_End(SHA256_CTX* context, char buffer[]) {
+         sha2_byte	digest[SHA256_DIGEST_LENGTH], *d = digest;
+         int		i;
+ 
+@@ -669,16 +669,16 @@ char *SHA256_End(SHA256_CTX* context, char buffer[]) {
+         return buffer;
+ }
+ 
+-char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
++char* pSHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
+         SHA256_CTX	context;
+ 
+         pSHA256_Init(&context);
+         pSHA256_Update(&context, data, len);
+-        return SHA256_End(&context, digest);
++        return pSHA256_End(&context, digest);
+ }
+ 
+ /*** SHA-512: *********************************************************/
+-void SHA512_Init(SHA512_CTX* context) {
++void pSHA512_Init(SHA512_CTX* context) {
+         if (context == (SHA512_CTX*)0) {
+                 return;
+         }
+@@ -855,7 +855,7 @@ void pSHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ 
+ #endif /* SHA2_UNROLL_TRANSFORM */
+ 
+-void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
++void pSHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
+         unsigned int	freespace, usedspace;
+ 
+         if (len == 0) {
+@@ -903,7 +903,7 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
+         usedspace = freespace = 0;
+ }
+ 
+-void SHA512_Last(SHA512_CTX* context) {
++void pSHA512_Last(SHA512_CTX* context) {
+         unsigned int	usedspace;
+ 
+         usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+@@ -944,7 +944,7 @@ void SHA512_Last(SHA512_CTX* context) {
+         pSHA512_Transform(context, (sha2_word64*)context->buffer);
+ }
+ 
+-void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
++void pSHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+         sha2_word64	*d = (sha2_word64*)digest;
+ 
+         /* Sanity check: */
+@@ -952,7 +952,7 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+ 
+         /* If no digest buffer is passed, we don't bother doing this: */
+         if (digest != (sha2_byte*)0) {
+-                SHA512_Last(context);
++                pSHA512_Last(context);
+ 
+                 /* Save the hash data for output: */
+ #if BYTE_ORDER == LITTLE_ENDIAN
+@@ -973,7 +973,7 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+         MEMSET_BZERO(context, sizeof(*context));
+ }
+ 
+-char *SHA512_End(SHA512_CTX* context, char buffer[]) {
++char *pSHA512_End(SHA512_CTX* context, char buffer[]) {
+         sha2_byte	digest[SHA512_DIGEST_LENGTH], *d = digest;
+         int		i;
+ 
+@@ -981,7 +981,7 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) {
+         assert(context != (SHA512_CTX*)0);
+ 
+         if (buffer != (char*)0) {
+-                SHA512_Final(digest, context);
++                pSHA512_Final(digest, context);
+ 
+                 for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
+                         *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+@@ -996,16 +996,16 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) {
+         return buffer;
+ }
+ 
+-char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
++char* pSHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
+         SHA512_CTX	context;
+ 
+-        SHA512_Init(&context);
+-        SHA512_Update(&context, data, len);
+-        return SHA512_End(&context, digest);
++        pSHA512_Init(&context);
++        pSHA512_Update(&context, data, len);
++        return pSHA512_End(&context, digest);
+ }
+ 
+ /*** SHA-384: *********************************************************/
+-void SHA384_Init(SHA384_CTX* context) {
++void pSHA384_Init(SHA384_CTX* context) {
+         if (context == (SHA384_CTX*)0) {
+                 return;
+         }
+@@ -1014,11 +1014,11 @@ void SHA384_Init(SHA384_CTX* context) {
+         context->bitcount[0] = context->bitcount[1] = 0;
+ }
+ 
+-void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
+-        SHA512_Update((SHA512_CTX*)context, data, len);
++void pSHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
++        pSHA512_Update((SHA512_CTX*)context, data, len);
+ }
+ 
+-void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
++void pSHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+         sha2_word64	*d = (sha2_word64*)digest;
+ 
+         /* Sanity check: */
+@@ -1026,7 +1026,7 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+ 
+         /* If no digest buffer is passed, we don't bother doing this: */
+         if (digest != (sha2_byte*)0) {
+-                SHA512_Last((SHA512_CTX*)context);
++                pSHA512_Last((SHA512_CTX*)context);
+ 
+                 /* Save the hash data for output: */
+ #if BYTE_ORDER == LITTLE_ENDIAN
+@@ -1047,7 +1047,7 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+         MEMSET_BZERO(context, sizeof(*context));
+ }
+ 
+-char *SHA384_End(SHA384_CTX* context, char buffer[]) {
++char *pSHA384_End(SHA384_CTX* context, char buffer[]) {
+         sha2_byte	digest[SHA384_DIGEST_LENGTH], *d = digest;
+         int		i;
+ 
+@@ -1055,7 +1055,7 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) {
+         assert(context != (SHA384_CTX*)0);
+ 
+         if (buffer != (char*)0) {
+-                SHA384_Final(digest, context);
++                pSHA384_Final(digest, context);
+ 
+                 for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
+                         *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+@@ -1070,10 +1070,10 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) {
+         return buffer;
+ }
+ 
+-char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
++char* pSHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
+         SHA384_CTX	context;
+ 
+-        SHA384_Init(&context);
+-        SHA384_Update(&context, data, len);
+-        return SHA384_End(&context, digest);
++        pSHA384_Init(&context);
++        pSHA384_Update(&context, data, len);
++        return pSHA384_End(&context, digest);
+ }


Home | Main Index | Thread Index | Old Index