Browse code

force alignment of ancillary data buffer (bb #1425).

git-svn: trunk@4858

Török Edvin authored on 2009/02/25 05:18:53
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Feb 24 22:50:21 EET 2009 (edwin)
2
+------------------------------------
3
+ * clamd/others.c: force alignment of ancillary data buffer (bb
4
+ #1425).
5
+
1 6
 Tue Feb 24 22:48:48 EET 2009 (edwin)
2 7
 ------------------------------------
3 8
  * configure, m4/acinclude.m4: add missing AC_RESULT.
... ...
@@ -273,7 +273,10 @@ static int read_fd_data(struct fd_buf *buf)
273 273
   {
274 274
       struct msghdr msg;
275 275
       struct cmsghdr *cmsg;
276
-      unsigned char buff[CMSG_SPACE(sizeof(int))];
276
+      union {
277
+       unsigned char buff[CMSG_SPACE(sizeof(int))];
278
+       struct cmsghdr hdr;
279
+      } b;
277 280
       struct iovec iov[1];
278 281
 
279 282
       if (buf->recvfd != -1) {
... ...
@@ -286,8 +289,8 @@ static int read_fd_data(struct fd_buf *buf)
286 286
       iov[0].iov_len = buf->bufsize - buf->off;
287 287
       msg.msg_iov = iov;
288 288
       msg.msg_iovlen = 1;
289
-      msg.msg_control = buff;
290
-      msg.msg_controllen = sizeof(buff);
289
+      msg.msg_control = b.buff;
290
+      msg.msg_controllen = CMSG_LEN(sizeof(int));
291 291
 
292 292
       n = recvmsg(buf->fd, &msg, 0);
293 293
       if (n < 0)