Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2103218

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, butbuildfarm results exposed the problem.
1 parent8232d6d commit2103218

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, (unsignedchar*)ptr,len);
319+
/* we assume sizeof MD5 result is 16, same as UUID size */
319320
MD5Final((unsignedchar*)&uu,&ctx);
320321
}
321322
else
322323
{
323324
SHA1_CTXctx;
325+
unsignedcharsha1result[SHA1_RESULTLEN];
324326

325327
SHA1Init(&ctx);
326328
SHA1Update(&ctx,ns,sizeof(uu));
327329
SHA1Update(&ctx, (unsignedchar*)ptr,len);
328-
SHA1Final((unsignedchar*)&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)

[8]ページ先頭

©2009-2025 Movatter.jp