Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: src/trusted/desc/posix/nacl_desc_conn_cap.c

Issue 3026044: Fix one uninitialized and one incorrectly initialized arguments in sendmsg sy... (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Native Client Authors. All rights reserved. 2 * Copyright 2010 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * NaCl Service Runtime. I/O Descriptor / Handle abstraction. 8 * NaCl Service Runtime. I/O Descriptor / Handle abstraction.
9 * Connection capabilities. 9 * Connection capabilities.
10 */ 10 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 iovec.iov_base = "c"; 95 iovec.iov_base = "c";
96 iovec.iov_len = 1; 96 iovec.iov_len = 1;
97 connect_msg.msg_iov = &iovec; 97 connect_msg.msg_iov = &iovec;
98 connect_msg.msg_iovlen = 1; 98 connect_msg.msg_iovlen = 1;
99 connect_msg.msg_name = NULL; 99 connect_msg.msg_name = NULL;
100 connect_msg.msg_namelen = 0; 100 connect_msg.msg_namelen = 0;
101 connect_msg.msg_control = control_buf; 101 connect_msg.msg_control = control_buf;
102 connect_msg.msg_controllen = sizeof(control_buf); 102 connect_msg.msg_controllen = sizeof(control_buf);
103 connect_msg.msg_flags = 0;
103 104
104 cmsg = CMSG_FIRSTHDR(&connect_msg); 105 cmsg = CMSG_FIRSTHDR(&connect_msg);
105 cmsg->cmsg_len = CMSG_LEN(sizeof(int)); 106 cmsg->cmsg_len = CMSG_LEN(sizeof(int));
106 cmsg->cmsg_level = SOL_SOCKET; 107 cmsg->cmsg_level = SOL_SOCKET;
107 cmsg->cmsg_type = SCM_RIGHTS; 108 cmsg->cmsg_type = SCM_RIGHTS;
108 /* We use memcpy() rather than assignment through a cast to avoid 109 /* We use memcpy() rather than assignment through a cast to avoid
109 strict-aliasing warnings */ 110 strict-aliasing warnings */
110 memcpy(CMSG_DATA(cmsg), &sock_pair[0], sizeof(int)); 111 memcpy(CMSG_DATA(cmsg), &sock_pair[0], sizeof(int));
112 /* Set msg_controllen to the actual size of the cmsg. */
113 connect_msg.msg_controllen = cmsg->cmsg_len;
111 114
112 sent = sendmsg(self->connect_fd, &connect_msg, 0); 115 sent = sendmsg(self->connect_fd, &connect_msg, 0);
113 NaClClose(sock_pair[0]); 116 NaClClose(sock_pair[0]);
114 if (sent != 1) { 117 if (sent != 1) {
115 NaClClose(sock_pair[1]); 118 NaClClose(sock_pair[1]);
116 return -NACL_ABI_EIO; 119 return -NACL_ABI_EIO;
117 } 120 }
118 121
119 connected_socket = malloc(sizeof(*connected_socket)); 122 connected_socket = malloc(sizeof(*connected_socket));
120 if (connected_socket == NULL || 123 if (connected_socket == NULL ||
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (!NaClDescCtor(&conn_cap->base)) { 185 if (!NaClDescCtor(&conn_cap->base)) {
183 free(conn_cap); 186 free(conn_cap);
184 return -NACL_ABI_ENOMEM; 187 return -NACL_ABI_ENOMEM;
185 } 188 }
186 conn_cap->base.vtbl = &kNaClDescConnCapFdVtbl; 189 conn_cap->base.vtbl = &kNaClDescConnCapFdVtbl;
187 conn_cap->connect_fd = *xfer->next_handle; 190 conn_cap->connect_fd = *xfer->next_handle;
188 *xfer->next_handle++ = NACL_INVALID_HANDLE; 191 *xfer->next_handle++ = NACL_INVALID_HANDLE;
189 *result = &conn_cap->base; 192 *result = &conn_cap->base;
190 return 0; 193 return 0;
191 } 194 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698