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

Commitea43fec

Browse files
committed
Fix problem with new pg_hba.conf code where the same comparison function
was incorrectly used for both qsort and bsearch.
1 parent6c59886 commitea43fec

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

‎src/backend/libpq/hba.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.82 2002/04/25 00:56:36 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.83 2002/04/28 22:49:07 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -335,21 +335,36 @@ tokenize_file(FILE *file)
335335

336336

337337
/*
338-
* Compare twopassword-filelines onthe basis oftheir user names.
338+
* Compare two linesbasedon their user/group names.
339339
*
340-
* Used for qsort() sorting and bsearch() lookup.
340+
* Used for qsort() sorting.
341341
*/
342342
staticint
343-
user_group_cmp(constvoid*user,constvoid*list)
343+
user_group_qsort_cmp(constvoid*list1,constvoid*list2)
344344
{
345345
/* first node is line number */
346-
char*user1=(char*)user;
347-
char*user2=lfirst(lnext(*(List**)list));
346+
char*user1=lfirst(lnext(*(List**)list1));
347+
char*user2=lfirst(lnext(*(List**)list2));
348348

349349
returnstrcmp(user1,user2);
350350
}
351351

352352

353+
/*
354+
* Compare two lines based on their user/group names.
355+
*
356+
* Used for bsearch() lookup.
357+
*/
358+
staticint
359+
user_group_bsearch_cmp(constvoid*user,constvoid*list)
360+
{
361+
/* first node is line number */
362+
char*user2=lfirst(lnext(*(List**)list));
363+
364+
returnstrcmp(user,user2);
365+
}
366+
367+
353368
/*
354369
* Lookup a group name in the pg_group file
355370
*/
@@ -360,7 +375,7 @@ get_group_line(const char *group)
360375
(void*)group_sorted,
361376
group_length,
362377
sizeof(List*),
363-
user_group_cmp);
378+
user_group_bsearch_cmp);
364379
}
365380

366381

@@ -374,7 +389,7 @@ get_user_line(const char *user)
374389
(void*)user_sorted,
375390
user_length,
376391
sizeof(List*),
377-
user_group_cmp);
392+
user_group_bsearch_cmp);
378393
}
379394

380395

@@ -754,7 +769,7 @@ load_group()
754769
foreach(line,group_lines)
755770
group_sorted[i++]=lfirst(line);
756771

757-
qsort((void*)group_sorted,group_length,sizeof(List*),user_group_cmp);
772+
qsort((void*)group_sorted,group_length,sizeof(List*),user_group_qsort_cmp);
758773
}
759774
else
760775
group_sorted=NULL;
@@ -792,7 +807,7 @@ load_user()
792807
foreach(line,user_lines)
793808
user_sorted[i++]=lfirst(line);
794809

795-
qsort((void*)user_sorted,user_length,sizeof(List*),user_group_cmp);
810+
qsort((void*)user_sorted,user_length,sizeof(List*),user_group_qsort_cmp);
796811
}
797812
else
798813
user_sorted=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp