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

Commit291ec6e

Browse files
committed
Suppress integer-overflow compiler warning for inconsistent sun_len.
On AIX 7.1, struct sockaddr_un is declared to be 1025 bytes long,but the sun_len field that should hold the length is only a byte.Clamp the value we try to store to ensure it will fit in the field.(This coding might need adjustment if there are any machines outthere where sun_len is as wide as size_t; but a preliminary surveysuggests there's not, so let's keep it simple.)Discussion:https://postgr.es/m/2781112.1644819528@sss.pgh.pa.us
1 parentfd2abeb commit291ec6e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/common/ip.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,18 @@ getaddrinfo_unix(const char *path, const struct addrinfo *hintsp,
232232
aip->ai_addrlen= offsetof(structsockaddr_un,sun_path)+strlen(path);
233233
}
234234

235+
/*
236+
* The standard recommendation for filling sun_len is to set it to the
237+
* struct size (independently of the actual path length). However, that
238+
* draws an integer-overflow warning on AIX 7.1, where sun_len is just
239+
* uint8 yet the struct size exceeds 255 bytes. It's likely that nothing
240+
* is paying attention to sun_len on that platform, but we have to do
241+
* something with it. To suppress the warning, clamp the struct size to
242+
* what will fit in sun_len.
243+
*/
235244
#ifdefHAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN
236-
unp->sun_len=sizeof(structsockaddr_un);
245+
unp->sun_len=Min(sizeof(structsockaddr_un),
246+
((size_t)1 << (sizeof(unp->sun_len)*BITS_PER_BYTE))-1);
237247
#endif
238248

239249
return0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp