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

Commit3455ddb

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 parente0e1ef4 commit3455ddb

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
@@ -2384,13 +2384,15 @@ CheckCertAuth(Port *port)
23842384
*/
23852385

23862386
/*
2387-
* RADIUS authentication is described in RFC2865 (and several
2388-
* others).
2387+
* RADIUS authentication is described in RFC2865 (and several others).
23892388
*/
23902389

23912390
#defineRADIUS_VECTOR_LENGTH 16
23922391
#defineRADIUS_HEADER_LENGTH 20
23932392

2393+
/* Maximum size of a RADIUS packet we will create or accept */
2394+
#defineRADIUS_BUFFER_SIZE 1024
2395+
23942396
typedefstruct
23952397
{
23962398
uint8attribute;
@@ -2404,6 +2406,8 @@ typedef struct
24042406
uint8id;
24052407
uint16length;
24062408
uint8vector[RADIUS_VECTOR_LENGTH];
2409+
/* this is a bit longer than strictly necessary: */
2410+
charpad[RADIUS_BUFFER_SIZE-RADIUS_VECTOR_LENGTH];
24072411
}radius_packet;
24082412

24092413
/* RADIUS packet types */
@@ -2420,9 +2424,6 @@ typedef struct
24202424
/* RADIUS service types */
24212425
#defineRADIUS_AUTHENTICATE_ONLY8
24222426

2423-
/* Maximum size of a RADIUS packet we will create or accept */
2424-
#defineRADIUS_BUFFER_SIZE 1024
2425-
24262427
/* Seconds to wait - XXX: should be in a config variable! */
24272428
#defineRADIUS_TIMEOUT 3
24282429

@@ -2458,10 +2459,12 @@ CheckRADIUSAuth(Port *port)
24582459
{
24592460
char*passwd;
24602461
char*identifier="postgresql";
2461-
charradius_buffer[RADIUS_BUFFER_SIZE];
2462-
charreceive_buffer[RADIUS_BUFFER_SIZE];
2463-
radius_packet*packet= (radius_packet*)radius_buffer;
2464-
radius_packet*receivepacket= (radius_packet*)receive_buffer;
2462+
radius_packetradius_send_pack;
2463+
radius_packetradius_recv_pack;
2464+
radius_packet*packet=&radius_send_pack;
2465+
radius_packet*receivepacket=&radius_recv_pack;
2466+
char*radius_buffer= (char*)&radius_send_pack;
2467+
char*receive_buffer= (char*)&radius_recv_pack;
24652468
int32service=htonl(RADIUS_AUTHENTICATE_ONLY);
24662469
uint8*cryptvector;
24672470
uint8encryptedpassword[RADIUS_VECTOR_LENGTH];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp