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

Commit2df854f

Browse files
committed
Fix misuse of memcpy() in check_ip().
The previous coding copied garbage into a local variable, pretty muchensuring that the intended test of an IPv6 connection address against apromoted IPv4 address from pg_hba.conf would never match. The lack offield complaints likely indicates that nobody realized this was supposedto work, which is unsurprising considering that no user-facing docs suggestit should work.In principle this could have led to a SIGSEGV due to reading off the end ofmemory, but since the source address would have pointed to somewhere in thefunction's stack frame, that's quite unlikely. What led to discovery ofthe bug is Hugo Osvaldo Barrera's report of a crash after an OS upgrade,which is probably because he is now running a system in which memcpy raisesabort() upon detecting overlapping source and destination areas. (You'dhave to additionally suppose some things about the stack frame layout toarrive at this conclusion, but it seems plausible.)This has been broken since the code was added, in commitf3aec2c,so back-patch to all supported branches.
1 parent94e7b84 commit2df854f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/backend/libpq/hba.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,8 @@ check_ip(SockAddr *raddr, struct sockaddr * addr, struct sockaddr * mask)
706706
structsockaddr_storageaddrcopy,
707707
maskcopy;
708708

709-
memcpy(&addrcopy,&addr,sizeof(addrcopy));
710-
memcpy(&maskcopy,&mask,sizeof(maskcopy));
709+
memcpy(&addrcopy,addr,sizeof(addrcopy));
710+
memcpy(&maskcopy,mask,sizeof(maskcopy));
711711
pg_promote_v4_to_v6_addr(&addrcopy);
712712
pg_promote_v4_to_v6_mask(&maskcopy);
713713

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp