Re: [BUG/PATCH] backend crashes during authentication if

Поиск
Список
Период
Сортировка
От Michael Wildpaner
Тема Re: [BUG/PATCH] backend crashes during authentication if
Дата
Msg-id Pine.LNX.4.58.0312052221120.732@rainbow.studorg.tuwien.ac.at
обсуждение исходный текст
Ответ на Re: [BUG/PATCH] backend crashes during authentication if data/global/pg_pwd is empty  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On Fri, 5 Dec 2003, Tom Lane wrote:
> > Hm, Solaris' bsearch() fails on empty input?  How bizarre.
>
> I was skeptical but apparently this is a known bug ...
> googling turned up a couple of references, eg
> http://www.opencm.org/pipermail/opencm-dev/2002-July/001077.html

in defense of Solaris' bsearch it should be said that it only breaks if
one passes NULL as the array base, a decidedly undefined (and unfriendly)
case. Passing an array with zero elements works as advertised. Btw, the
same happens on IRIX.

Best wishes, Mike

PS: A little program to demonstrate this: array with elements, empty   array, NULL pointer as base:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char strings[][4] = { "abc", "efg", "hij", "klm" };

typedef int (*cmp_t)(const void*, const void*);

int main(int argc, char**argv) { char *s, *term = "hij";
 s = bsearch(term, strings, sizeof(strings)/sizeof(char[4]),               sizeof(char*), (cmp_t) strcmp);
fprintf(stderr,"1: %s\n", (s != NULL) ? s : "<not found>");
 
 s = bsearch(term, strings, 0, sizeof(char*), (cmp_t) strcmp); fprintf(stderr, "2: %s\n", (s != NULL) ? s : "<not
found>");
 s = bsearch(term, NULL, 0, sizeof(char*), (cmp_t) strcmp); fprintf(stderr, "3: %s\n", (s != NULL) ? s : "<not
found>");
 return 0;
}

Results:

$ ./a.out      # Solaris 9
1: hij
2: <not found>
Segmentation Fault (core dumped)


$ ./a.out      # IRIX 6.5
1: hij
2: <not found>
Segmentation fault (core dumped)


$ ./a.out      # Linux with glibc 2.2.5
1: hij
2: <not found>
3: <not found>


$ ./a.out      # OpenBSD 3.2
1: hij
2: <not found>
3: <not found>

-- 
Life is like a fire.                            DI Michael Wildpaner
Flames which the passer-by forgets.                    Ph.D. Student
Ashes which the wind scatters.
A man lived.       -- Omar Khayyam


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Proposed Query Planner TODO items
Следующее
От: Joe Conway
Дата:
Сообщение: Re: bytea, index and like operator again and detailed report