mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Make minor improvements
This commit is contained in:
parent
221817e537
commit
4864565198
41 changed files with 394 additions and 367 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -36,12 +37,14 @@
|
|||
*/
|
||||
int bind(int fd, const void *addr, uint32_t addrsize) {
|
||||
if (!addr) return efault();
|
||||
if (IsAsan() && !__asan_is_valid(addr, addrsize)) return efault();
|
||||
if (addrsize == sizeof(struct sockaddr_in)) {
|
||||
if (!IsWindows()) {
|
||||
if (!IsBsd()) {
|
||||
return sys_bind(fd, addr, addrsize);
|
||||
} else {
|
||||
char addr2[sizeof(struct sockaddr_un_bsd)]; /* sockaddr_un_bsd is the largest */
|
||||
char addr2[sizeof(
|
||||
struct sockaddr_un_bsd)]; /* sockaddr_un_bsd is the largest */
|
||||
assert(addrsize <= sizeof(addr2));
|
||||
memcpy(&addr2, addr, addrsize);
|
||||
sockaddr2bsd(&addr2[0]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue