freebsd-ports/sysutils/fcron/files/patch-socket.c
Sergey Matveychuk c616f81865 - Install pam files directly (in /etc/pam.d, unless they already exist)
rather than just leaving them in the examples directory.  There seems
  to be no real security advantage to not installing the pam files since
  they are required for fcron and fcrontab to operate, and root privs are
  required to install fcron to begin with.

- The sockaddr.sa_len was not set prior to calls to bind() and connect().
  The upshot begin that fcrondyn was unable to open the socket
  to communicate with fcron.

PR:		ports/97066
Submitted by:	maintainer
2006-06-04 20:09:42 +00:00

34 lines
1.1 KiB
C

--- socket.c.orig Mon Feb 6 14:44:52 2006
+++ socket.c Tue May 9 16:33:19 2006
@@ -134,6 +134,7 @@
{
struct sockaddr_un addr;
int len = 0;
+ int sa_len;
/* used in fcron.c:main_loop():select() */
FD_ZERO(&read_set);
@@ -145,15 +146,19 @@
}
addr.sun_family = AF_UNIX;
- if ( (len = strlen(fifofile)) > sizeof(addr.sun_path) ) {
- error("Error : fifo file path too long (max is %d)", sizeof(addr.sun_path));
+ if ( (len = strlen(fifofile)) > sizeof(addr.sun_path) - 1) {
+ error("Error : fifo file path too long (max is %d)", sizeof(addr.sun_path) - 1);
goto err;
}
- strncpy(addr.sun_path, fifofile, sizeof(addr.sun_path) - 1);
+ strncpy(addr.sun_path, fifofile, sizeof(addr.sun_path));
addr.sun_path[sizeof(addr.sun_path) -1 ] = '\0';
+ sa_len = (addr.sun_path - (char *)&addr) + len;
+#if HAVE_SA_LEN
+ addr.sun_len = sa_len;
+#endif
unlink(fifofile);
- if (bind(listen_fd, (struct sockaddr*) &addr, sizeof(addr.sun_family)+len+1) != 0){
+ if (bind(listen_fd, (struct sockaddr*) &addr, sa_len) != 0){
error_e("Cannot bind socket to '%s'", fifofile);
goto err;
}