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

Commit742d0f2

Browse files
committed
Clean up comments.
1 parent2a314ad commit742d0f2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

‎src/backend/libpq/md5.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
*
1111
* Sverre H. Huseby <sverrehu@online.no>
1212
*
13-
* $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.7 2001/09/27 23:16:23 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.8 2001/09/29 19:49:50 tgl Exp $
1414
*/
1515

1616
#include"postgres.h"
1717

18-
#include<errno.h>
19-
2018
#include"libpq/crypt.h"
2119

2220
#ifdefFRONTEND
@@ -291,24 +289,31 @@ md5_hash(const void *buff, size_t len, char *hexsum)
291289

292290

293291
/*
294-
* puts md5(username+passwd) in buf provided buflen is at least 36 bytes
295-
* returns 1 on success, 0 on any kind of failure and sets errno accordingly
292+
* Computes MD5 checksum of "passwd" (a null-terminated string) followed
293+
* by "salt" (which need not be null-terminated).
294+
*
295+
* Output format is "md5" followed by a 32-hex-digit MD5 checksum.
296+
* Hence, the output buffer "buf" must be at least 36 bytes long.
297+
*
298+
* Returns TRUE if okay, FALSE on error (out of memory).
296299
*/
297300
boolEncryptMD5(constchar*passwd,constchar*salt,size_tsalt_len,
298301
char*buf)
299302
{
300-
char*crypt_buf=palloc(strlen(passwd)+salt_len);
303+
size_tpasswd_len=strlen(passwd);
304+
char*crypt_buf=palloc(passwd_len+salt_len);
301305
boolret;
302306

303-
strcpy(buf,"md5");
304307
/*
305308
*Place salt at the end because it may be known by users
306309
*trying to crack the MD5 output.
307310
*/
308311
strcpy(crypt_buf,passwd);
309-
memcpy(crypt_buf+strlen(passwd),salt,salt_len);
312+
memcpy(crypt_buf+passwd_len,salt,salt_len);
313+
314+
strcpy(buf,"md5");
315+
ret=md5_hash(crypt_buf,passwd_len+salt_len,buf+3);
310316

311-
ret=md5_hash(crypt_buf,strlen(passwd)+salt_len,buf+3);
312317
pfree(crypt_buf);
313318

314319
returnret;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp