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

Commit4c051c4

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 parent7cbd944 commit4c051c4

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
@@ -2570,14 +2570,16 @@ CheckCertAuth(Port *port)
25702570
*/
25712571

25722572
/*
2573-
* RADIUS authentication is described in RFC2865 (and several
2574-
* others).
2573+
* RADIUS authentication is described in RFC2865 (and several others).
25752574
*/
25762575

25772576
#defineRADIUS_VECTOR_LENGTH 16
25782577
#defineRADIUS_HEADER_LENGTH 20
25792578
#defineRADIUS_MAX_PASSWORD_LENGTH 128
25802579

2580+
/* Maximum size of a RADIUS packet we will create or accept */
2581+
#defineRADIUS_BUFFER_SIZE 1024
2582+
25812583
typedefstruct
25822584
{
25832585
uint8attribute;
@@ -2591,6 +2593,8 @@ typedef struct
25912593
uint8id;
25922594
uint16length;
25932595
uint8vector[RADIUS_VECTOR_LENGTH];
2596+
/* this is a bit longer than strictly necessary: */
2597+
charpad[RADIUS_BUFFER_SIZE-RADIUS_VECTOR_LENGTH];
25942598
}radius_packet;
25952599

25962600
/* RADIUS packet types */
@@ -2607,9 +2611,6 @@ typedef struct
26072611
/* RADIUS service types */
26082612
#defineRADIUS_AUTHENTICATE_ONLY8
26092613

2610-
/* Maximum size of a RADIUS packet we will create or accept */
2611-
#defineRADIUS_BUFFER_SIZE 1024
2612-
26132614
/* Seconds to wait - XXX: should be in a config variable! */
26142615
#defineRADIUS_TIMEOUT 3
26152616

@@ -2734,10 +2735,12 @@ CheckRADIUSAuth(Port *port)
27342735
staticint
27352736
PerformRadiusTransaction(char*server,char*secret,char*portstr,char*identifier,char*user_name,char*passwd)
27362737
{
2737-
charradius_buffer[RADIUS_BUFFER_SIZE];
2738-
charreceive_buffer[RADIUS_BUFFER_SIZE];
2739-
radius_packet*packet= (radius_packet*)radius_buffer;
2740-
radius_packet*receivepacket= (radius_packet*)receive_buffer;
2738+
radius_packetradius_send_pack;
2739+
radius_packetradius_recv_pack;
2740+
radius_packet*packet=&radius_send_pack;
2741+
radius_packet*receivepacket=&radius_recv_pack;
2742+
char*radius_buffer= (char*)&radius_send_pack;
2743+
char*receive_buffer= (char*)&radius_recv_pack;
27412744
int32service=htonl(RADIUS_AUTHENTICATE_ONLY);
27422745
uint8*cryptvector;
27432746
intencryptedpasswordlen;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp