Content-Length: 277906 | pFad | http://github.com/postgrespro/postgres/commit/2103218dd4a0c6a44d05c09c066da20e1c2360fb

6E Fix stack clobber in new uuid-ossp code. · postgrespro/postgres@2103218 · GitHub
Skip to content

Commit 2103218

Browse files
committed
Fix stack clobber in new uuid-ossp code.
The V5 (SHA1 hashing) code wrote 20 bytes into a 16-byte local variable. This had accidentally failed to fail in my testing and Matteo's, but buildfarm results exposed the problem.
1 parent 8232d6d commit 2103218

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

contrib/uuid-ossp/uuid-ossp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,19 @@ uuid_generate_internal(int v, unsigned char *ns, char *ptr, int len)
316316
MD5Init(&ctx);
317317
MD5Update(&ctx, ns, sizeof(uu));
318318
MD5Update(&ctx, (unsigned char *) ptr, len);
319+
/* we assume sizeof MD5 result is 16, same as UUID size */
319320
MD5Final((unsigned char *) &uu, &ctx);
320321
}
321322
else
322323
{
323324
SHA1_CTX ctx;
325+
unsigned char sha1result[SHA1_RESULTLEN];
324326

325327
SHA1Init(&ctx);
326328
SHA1Update(&ctx, ns, sizeof(uu));
327329
SHA1Update(&ctx, (unsigned char *) ptr, len);
328-
SHA1Final((unsigned char *) &uu, &ctx);
330+
SHA1Final(sha1result, &ctx);
331+
memcpy(&uu, sha1result, sizeof(uu));
329332
}
330333

331334
/* the calculated hash is using local order */

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/2103218dd4a0c6a44d05c09c066da20e1c2360fb

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy