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

Commit86dba33

Browse files
committed
Replace calls of htonl()/ntohl() with pg_bswap.h for GSSAPI encryption
The in-core equivalents can make use of built-in functions if thecompiler supports this option, making optimizations possible.0ba99c8replaced all existing calls in the code base at this time, butb0b39f7(GSSAPI encryption) has forgotten to do the switch.Discussion:https://postgr.es/m/20201014055303.GG3349@paquier.xyz
1 parent8176afd commit86dba33

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

‎src/backend/libpq/be-secure-gssapi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ be_gssapi_write(Port *port, void *ptr, size_t len)
209209
PqGSSSendConsumed+=input.length;
210210

211211
/* 4 network-order bytes of length, then payload */
212-
netlen=htonl(output.length);
212+
netlen=pg_hton32(output.length);
213213
memcpy(PqGSSSendBuffer+PqGSSSendLength,&netlen,sizeof(uint32));
214214
PqGSSSendLength+=sizeof(uint32);
215215

@@ -323,7 +323,7 @@ be_gssapi_read(Port *port, void *ptr, size_t len)
323323
}
324324

325325
/* Decode the packet length and check for overlength packet */
326-
input.length=ntohl(*(uint32*)PqGSSRecvBuffer);
326+
input.length=pg_ntoh32(*(uint32*)PqGSSRecvBuffer);
327327

328328
if (input.length>PQ_GSS_RECV_BUFFER_SIZE-sizeof(uint32))
329329
ereport(FATAL,
@@ -509,7 +509,7 @@ secure_open_gssapi(Port *port)
509509
/*
510510
* Get the length for this packet from the length header.
511511
*/
512-
input.length=ntohl(*(uint32*)PqGSSRecvBuffer);
512+
input.length=pg_ntoh32(*(uint32*)PqGSSRecvBuffer);
513513

514514
/* Done with the length, reset our buffer */
515515
PqGSSRecvLength=0;
@@ -567,7 +567,7 @@ secure_open_gssapi(Port *port)
567567
*/
568568
if (output.length>0)
569569
{
570-
uint32netlen=htonl(output.length);
570+
uint32netlen=pg_hton32(output.length);
571571

572572
if (output.length>PQ_GSS_SEND_BUFFER_SIZE-sizeof(uint32))
573573
ereport(FATAL,

‎src/interfaces/libpq/fe-secure-gssapi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pg_GSS_write(PGconn *conn, const void *ptr, size_t len)
226226
PqGSSSendConsumed+=input.length;
227227

228228
/* 4 network-order bytes of length, then payload */
229-
netlen=htonl(output.length);
229+
netlen=pg_hton32(output.length);
230230
memcpy(PqGSSSendBuffer+PqGSSSendLength,&netlen,sizeof(uint32));
231231
PqGSSSendLength+=sizeof(uint32);
232232

@@ -346,7 +346,7 @@ pg_GSS_read(PGconn *conn, void *ptr, size_t len)
346346
}
347347

348348
/* Decode the packet length and check for overlength packet */
349-
input.length=ntohl(*(uint32*)PqGSSRecvBuffer);
349+
input.length=pg_ntoh32(*(uint32*)PqGSSRecvBuffer);
350350

351351
if (input.length>PQ_GSS_RECV_BUFFER_SIZE-sizeof(uint32))
352352
{
@@ -589,7 +589,7 @@ pqsecure_open_gss(PGconn *conn)
589589
*/
590590

591591
/* Get the length and check for over-length packet */
592-
input.length=ntohl(*(uint32*)PqGSSRecvBuffer);
592+
input.length=pg_ntoh32(*(uint32*)PqGSSRecvBuffer);
593593
if (input.length>PQ_GSS_RECV_BUFFER_SIZE-sizeof(uint32))
594594
{
595595
printfPQExpBuffer(&conn->errorMessage,
@@ -688,7 +688,7 @@ pqsecure_open_gss(PGconn *conn)
688688
}
689689

690690
/* Queue the token for writing */
691-
netlen=htonl(output.length);
691+
netlen=pg_hton32(output.length);
692692

693693
memcpy(PqGSSSendBuffer, (char*)&netlen,sizeof(uint32));
694694
PqGSSSendLength+=sizeof(uint32);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp