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

Commit1ed95ad

Browse files
trawickFelipe Zimmerle
authored and
Felipe Zimmerle
committed
Fix invalid storage reference by apr_psprintf() when creating a string from salt[]. salt[] is not '\0'-terminated, so apr_psprintf() needs to be told the extent of the bytes to read.
It is easy to test old/new code standalone with valgrind;jst insert the getkey() function into this template:-----------getkey() goes here-----------------int main(void){ apr_pool_t *p; apr_initialize(); apr_pool_create(&p, NULL); printf("%s\n", getkey(p)); return 0;}
1 parenta9a3925 commit1ed95ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎apache2/msc_crypt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ char *getkey(apr_pool_t *mp) {
152152
charsalt[64];
153153

154154
apr_generate_random_bytes(salt,sizeof(salt));
155-
key=apr_psprintf(mp,"%s",salt);
155+
key=apr_psprintf(mp,"%.*s",(int)sizeof(salt),salt);
156156

157157
apr_sha1_init (&ctx);
158158
apr_sha1_update (&ctx, (constchar*)key,strlen(key));
159159
apr_sha1_update (&ctx,"\0",1);
160160

161161
apr_generate_random_bytes(salt,sizeof(salt));
162-
value=apr_psprintf(mp,"%s",salt);
162+
value=apr_psprintf(mp,"%.*s",(int)sizeof(salt),salt);
163163

164164
apr_sha1_update (&ctx,value,strlen (value));
165165
apr_sha1_final (digest,&ctx);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp