linux_socket.c (f05531a3921c8305d78561fe794c5fed9d7800dd) linux_socket.c (c02637c71769cfb7a7687f7e4520edd56301aa90)
1/*-
2 * Copyright (c) 1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 76 unchanged lines hidden (view full) ---

85{
86 int error=0, bdom;
87 struct sockaddr *sa;
88 struct osockaddr *kosa;
89#ifdef INET6
90 int oldv6size;
91 struct sockaddr_in6 *sin6;
92#endif
1/*-
2 * Copyright (c) 1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 76 unchanged lines hidden (view full) ---

85{
86 int error=0, bdom;
87 struct sockaddr *sa;
88 struct osockaddr *kosa;
89#ifdef INET6
90 int oldv6size;
91 struct sockaddr_in6 *sin6;
92#endif
93 char *name;
93 int alloclen, hdrlen, namelen;
94
95 if (osalen < 2 || osalen > UCHAR_MAX || !osa)
96 return (EINVAL);
97
98 alloclen = osalen;
99#ifdef INET6
100 oldv6size = 0;

--- 52 unchanged lines hidden (view full) ---

153 if (osalen < alloclen) {
154 error = EINVAL;
155 goto out;
156 }
157 }
158
159 if (bdom == AF_LOCAL && osalen > sizeof(struct sockaddr_un)) {
160 hdrlen = offsetof(struct sockaddr_un, sun_path);
94 int alloclen, hdrlen, namelen;
95
96 if (osalen < 2 || osalen > UCHAR_MAX || !osa)
97 return (EINVAL);
98
99 alloclen = osalen;
100#ifdef INET6
101 oldv6size = 0;

--- 52 unchanged lines hidden (view full) ---

154 if (osalen < alloclen) {
155 error = EINVAL;
156 goto out;
157 }
158 }
159
160 if (bdom == AF_LOCAL && osalen > sizeof(struct sockaddr_un)) {
161 hdrlen = offsetof(struct sockaddr_un, sun_path);
161 namelen = strnlen(((struct sockaddr_un *)kosa)->sun_path,
162 osalen - hdrlen);
162 name = ((struct sockaddr_un *)kosa)->sun_path;
163 if (*name == '\0') {
164 /*
165 * Linux abstract namespace starts with a NULL byte.
166 * XXX We do not support abstract namespace yet.
167 */
168 namelen = strnlen(name + 1, osalen - hdrlen - 1) + 1;
169 } else
170 namelen = strnlen(name, osalen - hdrlen);
163 if (hdrlen + namelen > sizeof(struct sockaddr_un)) {
164 error = ENAMETOOLONG;
165 goto out;
166 }
167 alloclen = sizeof(struct sockaddr_un);
168 }
169
170 sa = (struct sockaddr *) kosa;

--- 1515 unchanged lines hidden ---
171 if (hdrlen + namelen > sizeof(struct sockaddr_un)) {
172 error = ENAMETOOLONG;
173 goto out;
174 }
175 alloclen = sizeof(struct sockaddr_un);
176 }
177
178 sa = (struct sockaddr *) kosa;

--- 1515 unchanged lines hidden ---