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

Commitc804c00

Browse files
committed
Fix unportable disregard of alignment requirements in RADIUS code.
The compiler is entitled to store a char[] local variable with noparticular alignment requirement. Our RADIUS code cavalierly took sucha local variable and cast its address to a struct type that does havealignment requirements. On an alignment-picky machine this would leadto bus errors. To fix, declare the local variable honestly, and thencast its address to char * for use in the I/O calls.Given the lack of field complaints, there must be very few if anypeople affected; but nonetheless this is a clear portability issue,so back-patch to all supported branches.Noted while looking at a Coverity complaint in the same code.
1 parent5674a25 commitc804c00

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

‎src/backend/libpq/auth.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,14 +2355,16 @@ CheckCertAuth(Port *port)
23552355
*/
23562356

23572357
/*
2358-
* RADIUS authentication is described in RFC2865 (and several
2359-
* others).
2358+
* RADIUS authentication is described in RFC2865 (and several others).
23602359
*/
23612360

23622361
#defineRADIUS_VECTOR_LENGTH 16
23632362
#defineRADIUS_HEADER_LENGTH 20
23642363
#defineRADIUS_MAX_PASSWORD_LENGTH 128
23652364

2365+
/* Maximum size of a RADIUS packet we will create or accept */
2366+
#defineRADIUS_BUFFER_SIZE 1024
2367+
23662368
typedefstruct
23672369
{
23682370
uint8attribute;
@@ -2376,6 +2378,8 @@ typedef struct
23762378
uint8id;
23772379
uint16length;
23782380
uint8vector[RADIUS_VECTOR_LENGTH];
2381+
/* this is a bit longer than strictly necessary: */
2382+
charpad[RADIUS_BUFFER_SIZE-RADIUS_VECTOR_LENGTH];
23792383
}radius_packet;
23802384

23812385
/* RADIUS packet types */
@@ -2392,9 +2396,6 @@ typedef struct
23922396
/* RADIUS service types */
23932397
#defineRADIUS_AUTHENTICATE_ONLY8
23942398

2395-
/* Maximum size of a RADIUS packet we will create or accept */
2396-
#defineRADIUS_BUFFER_SIZE 1024
2397-
23982399
/* Seconds to wait - XXX: should be in a config variable! */
23992400
#defineRADIUS_TIMEOUT 3
24002401

@@ -2429,10 +2430,12 @@ CheckRADIUSAuth(Port *port)
24292430
{
24302431
char*passwd;
24312432
char*identifier="postgresql";
2432-
charradius_buffer[RADIUS_BUFFER_SIZE];
2433-
charreceive_buffer[RADIUS_BUFFER_SIZE];
2434-
radius_packet*packet= (radius_packet*)radius_buffer;
2435-
radius_packet*receivepacket= (radius_packet*)receive_buffer;
2433+
radius_packetradius_send_pack;
2434+
radius_packetradius_recv_pack;
2435+
radius_packet*packet=&radius_send_pack;
2436+
radius_packet*receivepacket=&radius_recv_pack;
2437+
char*radius_buffer= (char*)&radius_send_pack;
2438+
char*receive_buffer= (char*)&radius_recv_pack;
24362439
int32service=htonl(RADIUS_AUTHENTICATE_ONLY);
24372440
uint8*cryptvector;
24382441
intencryptedpasswordlen;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp