From source_changes at macosforge.org Wed Jun 4 14:57:50 2008 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Wed, 4 Jun 2008 14:57:50 -0700 (PDT) Subject: [launchd-changes] [23640] trunk/launchd/src Message-ID: <20080604215750.7A57A172D26D@beta.macosforge.org> Revision: 23640 http://trac.macosforge.org/projects/launchd/changeset/23640 Author: zarzycki at apple.com Date: 2008-06-04 14:57:47 -0700 (Wed, 04 Jun 2008) Log Message: ----------- Preparing to crank up the warning level... Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchctl.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchproxy.c Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2008-05-28 20:33:08 UTC (rev 23639) +++ trunk/launchd/src/Makefile.am 2008-06-04 21:57:47 UTC (rev 23640) @@ -1,6 +1,6 @@ -CWARN = -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wmissing-prototypes -Wmissing-declarations -Werror # gcc4.2: -Wstrict-overflow=4 # -Wpadded -Wconversion -Wstrict-aliasing=2 -CTUNE = -fvisibility=hidden -freorder-blocks # gcc4.2: -fdiagnostics-show-option # -fstrict-aliasing -CMISC = -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -D__MigTypeCheck=1 -Dmig_external=__private_extern__ -D_DARWIN_USE_64_BIT_INODE=1 +CWARN = -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wmissing-prototypes -Wmissing-declarations -Werror -Wstrict-overflow=4 # -Wstrict-aliasing=2 -Wshorten-64-to-32 # -Wpadded -Wconversion +CTUNE = -fvisibility=hidden -freorder-blocks -fdiagnostics-show-option # -fstrict-aliasing +CMISC = -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -Dmig_external=__private_extern__ -D_DARWIN_USE_64_BIT_INODE=1 AM_CFLAGS = $(CTUNE) $(CMISC) $(CWARN) AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT) Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2008-05-28 20:33:08 UTC (rev 23639) +++ trunk/launchd/src/Makefile.in 2008-06-04 21:57:47 UTC (rev 23640) @@ -242,9 +242,9 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -CWARN = -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wmissing-prototypes -Wmissing-declarations -Werror # gcc4.2: -Wstrict-overflow=4 # -Wpadded -Wconversion -Wstrict-aliasing=2 -CTUNE = -fvisibility=hidden -freorder-blocks # gcc4.2: -fdiagnostics-show-option # -fstrict-aliasing -CMISC = -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -D__MigTypeCheck=1 -Dmig_external=__private_extern__ -D_DARWIN_USE_64_BIT_INODE=1 +CWARN = -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wmissing-prototypes -Wmissing-declarations -Werror -Wstrict-overflow=4 # -Wstrict-aliasing=2 -Wshorten-64-to-32 # -Wpadded -Wconversion +CTUNE = -fvisibility=hidden -freorder-blocks -fdiagnostics-show-option # -fstrict-aliasing +CMISC = -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -Dmig_external=__private_extern__ -D_DARWIN_USE_64_BIT_INODE=1 AM_CFLAGS = $(CTUNE) $(CMISC) $(CWARN) AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT) CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2008-05-28 20:33:08 UTC (rev 23639) +++ trunk/launchd/src/launchctl.c 2008-06-04 21:57:47 UTC (rev 23640) @@ -96,7 +96,7 @@ launch_data_t pass1; launch_data_t pass2; char *session_type; - unsigned int editondisk:1, load:1, forceload:1, __pad:29; + bool editondisk:1, load:1, forceload:1; }; static void myCFDictionaryApplyFunction(const void *key, const void *value, void *context); @@ -319,7 +319,8 @@ { char s[1000], *c, *av[100]; const char *file; - size_t len, i; + size_t len; + int i; FILE *f; if (getppid() == 1) { @@ -332,7 +333,7 @@ return; } - while ((c = fgets(s, sizeof(s), f))) { + while ((c = fgets(s, (int) sizeof s, f))) { len = strlen(c); if (len && c[len - 1] == '\n') { c[len - 1] = '\0'; @@ -916,7 +917,7 @@ return; } oldmask = umask(S_IRWXG|S_IRWXO); - if (bind(sfd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { + if (bind(sfd, (struct sockaddr *)&sun, (socklen_t) sizeof sun) == -1) { close(sfd); umask(oldmask); return; @@ -929,7 +930,7 @@ close(sfd); return; } - } else if (connect(sfd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { + } else if (connect(sfd, (struct sockaddr *)&sun, (socklen_t) sizeof sun) == -1) { close(sfd); return; } @@ -1003,17 +1004,17 @@ if (hints.ai_flags & AI_PASSIVE) { if (AF_INET6 == res->ai_family && -1 == setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, - (void *)&sock_opt, sizeof(sock_opt))) { + (void *)&sock_opt, (socklen_t) sizeof sock_opt)) { fprintf(stderr, "setsockopt(IPV6_V6ONLY): %m"); return; } if (mgroup) { - if (setsockopt(sfd, SOL_SOCKET, SO_REUSEPORT, (void *)&sock_opt, sizeof(sock_opt)) == -1) { + if (setsockopt(sfd, SOL_SOCKET, SO_REUSEPORT, (void *)&sock_opt, (socklen_t) sizeof sock_opt) == -1) { fprintf(stderr, "setsockopt(SO_REUSEPORT): %s\n", strerror(errno)); return; } } else { - if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&sock_opt, sizeof(sock_opt)) == -1) { + if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&sock_opt, (socklen_t) sizeof sock_opt) == -1) { fprintf(stderr, "setsockopt(SO_REUSEADDR): %s\n", strerror(errno)); return; } @@ -1108,7 +1109,7 @@ if (AF_INET == family) { memset(&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr = ((struct sockaddr_in *)res->ai_addr)->sin_addr; - if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) { + if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, (socklen_t) sizeof mreq) == -1) { fprintf(stderr, "setsockopt(IP_ADD_MEMBERSHIP): %s\n", strerror(errno)); continue; } @@ -1116,7 +1117,7 @@ } else if (AF_INET6 == family) { memset(&m6req, 0, sizeof(m6req)); m6req.ipv6mr_multiaddr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr; - if (setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &m6req, sizeof(m6req)) == -1) { + if (setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &m6req, (socklen_t) sizeof m6req) == -1) { fprintf(stderr, "setsockopt(IPV6_JOIN_GROUP): %s\n", strerror(errno)); continue; } @@ -1293,8 +1294,7 @@ help_cmd(int argc, char *const argv[]) { FILE *where = stdout; - int l, cmdwidth = 0; - size_t i; + size_t i, l, cmdwidth = 0; if (argc == 0 || argv == NULL) where = stderr; @@ -1303,12 +1303,13 @@ for (i = 0; i < (sizeof cmds / sizeof cmds[0]); i++) { l = strlen(cmds[i].name); - if (l > cmdwidth) + if (l > cmdwidth) { cmdwidth = l; + } } for (i = 0; i < (sizeof cmds / sizeof cmds[0]); i++) { - fprintf(where, "\t%-*s\t%s\n", cmdwidth, cmds[i].name, cmds[i].desc); + fprintf(where, "\t%-*s\t%s\n", (int)cmdwidth, cmds[i].name, cmds[i].desc); } return 0; @@ -2108,7 +2109,6 @@ logupdate_cmd(int argc, char *const argv[]) { int64_t inval, outval; - int i, j, m = 0; bool badargs = false, maskmode = false, onlymode = false, levelmode = false; static const struct { const char *name; @@ -2123,7 +2123,8 @@ { "alert", LOG_ALERT }, { "emergency", LOG_EMERG }, }; - int logtblsz = sizeof logtbl / sizeof logtbl[0]; + size_t i, j, logtblsz = sizeof logtbl / sizeof logtbl[0]; + int m = 0; if (argc >= 2) { if (!strcmp(argv[1], "mask")) @@ -2140,7 +2141,7 @@ m = LOG_UPTO(LOG_DEBUG); if (argc > 2 && (maskmode || onlymode)) { - for (i = 2; i < argc; i++) { + for (i = 2; i < (size_t)argc; i++) { for (j = 0; j < logtblsz; j++) { if (!strcmp(argv[i], logtbl[j].name)) { if (maskmode) @@ -2305,7 +2306,7 @@ for (i = 0; i < (lsz / sizeof(struct rlimit)); i++) { if (argc == 2 && (size_t)which != i) continue; - fprintf(stdout, "\t%-12s%-15s%-15s\n", num2name(i), + fprintf(stdout, "\t%-12s%-15s%-15s\n", num2name((int)i), lim2str(lmts[i].rlim_cur, slimstr), lim2str(lmts[i].rlim_max, hlimstr)); } @@ -3114,7 +3115,7 @@ if (assumes(prog != NULL)) { /* The networking team has asked us to ignore the failure of this API if errno == ENOPROTOOPT */ - assumes(setsockopt(sfd, SOL_SOCKET, SO_EXECPATH, prog, strlen(prog) + 1) != -1 || errno == ENOPROTOOPT); + assumes(setsockopt(sfd, SOL_SOCKET, SO_EXECPATH, prog, (socklen_t)(strlen(prog) + 1)) != -1 || errno == ENOPROTOOPT); } } Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-05-28 20:33:08 UTC (rev 23639) +++ trunk/launchd/src/launchd.c 2008-06-04 21:57:47 UTC (rev 23640) @@ -398,7 +398,7 @@ bool new_networking_state; char buf[1024]; - launchd_assumes(read(kev->ident, &buf, sizeof(buf)) != -1); + launchd_assumes(read((int)kev->ident, &buf, sizeof(buf)) != -1); new_networking_state = get_network_state(); Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-05-28 20:33:08 UTC (rev 23639) +++ trunk/launchd/src/launchd_core_logic.c 2008-06-04 21:57:47 UTC (rev 23640) @@ -188,7 +188,7 @@ }; }; -static bool socketgroup_new(job_t j, const char *name, int *fds, unsigned int fd_cnt, bool junkfds); +static bool socketgroup_new(job_t j, const char *name, int *fds, size_t fd_cnt, bool junkfds); static void socketgroup_delete(job_t j, struct socketgroup *sg); static void socketgroup_watch(job_t j, struct socketgroup *sg); static void socketgroup_ignore(job_t j, struct socketgroup *sg); @@ -357,6 +357,7 @@ mach_port_t wait_reply_port; /* we probably should switch to a list of waiters */ uid_t mach_uid; jobmgr_t mgr; + size_t argc; char **argv; char *prog; char *rootdir; @@ -379,15 +380,14 @@ size_t quarantine_data_sz; #endif pid_t p; - int argc; int last_exit_status; int stdin_fd; int fork_fd; int log_redirect_fd; int nice; - unsigned int timeout; - unsigned int exit_timeout; int stdout_err_fd; + uint32_t timeout; + uint32_t exit_timeout; uint64_t sent_signal_time; uint64_t start_time; uint32_t min_run_time; @@ -711,7 +711,7 @@ launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_STANDARDERRORPATH); } if (likely(j->argv) && (tmp = launch_data_alloc(LAUNCH_DATA_ARRAY))) { - int i; + size_t i; for (i = 0; i < j->argc; i++) { if ((tmp2 = launch_data_new_string(j->argv[i]))) { @@ -1069,7 +1069,7 @@ { launch_data_t tmp_oai; job_t j = context; - unsigned int i, fd_cnt = 1; + size_t i, fd_cnt = 1; int *fds; if (launch_data_get_type(obj) == LAUNCH_DATA_ARRAY) { @@ -1125,7 +1125,7 @@ } /* Sigh... at the moment, MIG has maxsize == sizeof(reply union) */ - mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); + mxmsgsz = (typeof(mxmsgsz)) sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; } @@ -1326,7 +1326,7 @@ const char *bn = NULL; char *co; size_t minlabel_len; - int i, cc = 0; + size_t i, cc = 0; job_t j; launchd_assert(offsetof(struct job_s, kqjob_callback) == 0); @@ -1706,15 +1706,21 @@ } else if (unlikely(value > UINT32_MAX)) { job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_EXITTIMEOUT); } else { - j->exit_timeout = value; + j->exit_timeout = (typeof(j->exit_timeout)) value; } } break; case 'n': case 'N': if (strcasecmp(key, LAUNCH_JOBKEY_NICE) == 0) { - j->nice = value; - j->setnice = true; + if (unlikely(value < PRIO_MIN)) { + job_log(j, LOG_WARNING, "%s less than %d. Ignoring.", LAUNCH_JOBKEY_NICE, PRIO_MIN); + } else if (unlikely(value > PRIO_MAX)) { + job_log(j, LOG_WARNING, "%s is greater than %d. Ignoring.", LAUNCH_JOBKEY_NICE, PRIO_MAX); + } else { + j->nice = (typeof(j->nice)) value; + j->setnice = true; + } } break; case 't': @@ -1725,7 +1731,7 @@ } else if (unlikely(value > UINT32_MAX)) { job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_TIMEOUT); } else { - j->timeout = value; + j->timeout = (typeof(j->timeout)) value; } } else if (strcasecmp(key, LAUNCH_JOBKEY_THROTTLEINTERVAL) == 0) { if (value < 0) { @@ -1733,7 +1739,7 @@ } else if (value > UINT32_MAX) { job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_THROTTLEINTERVAL); } else { - j->min_run_time = value; + j->min_run_time = (typeof(j->min_run_time)) value; } } break; @@ -1753,9 +1759,9 @@ job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_STARTINTERVAL); } else { runtime_add_weak_ref(); - j->start_interval = value; + j->start_interval = (typeof(j->start_interval)) value; - job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, value, j) != -1); + job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, j->start_interval, j) != -1); } #if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXFLAGS) == 0) { @@ -1948,7 +1954,7 @@ if (job_assumes(j, j->j_binpref = malloc(value_cnt * sizeof(*j->j_binpref)))) { j->j_binpref_cnt = value_cnt; for (i = 0; i < value_cnt; i++) { - j->j_binpref[i] = launch_data_get_integer(launch_data_array_get_index(value, i)); + j->j_binpref[i] = (cpu_type_t) launch_data_get_integer(launch_data_array_get_index(value, i)); } } } @@ -2321,7 +2327,7 @@ } if (unlikely(j->weird_bootstrap)) { - mach_msg_size_t mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); + mach_msg_size_t mxmsgsz = (typeof(mxmsgsz)) sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; @@ -2599,7 +2605,7 @@ #else int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; #endif - int mib_sz = sizeof(mib) / sizeof(mib[0]); + size_t mib_sz = sizeof(mib) / sizeof(mib[0]); size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc(); struct kinfo_proc *kp; @@ -2610,7 +2616,7 @@ if (!job_assumes(j, (kp = malloc(len)) != NULL)) { return; } - if (!job_assumes(j, sysctl(mib, mib_sz, kp, &len, NULL, 0) != -1)) { + if (!job_assumes(j, sysctl(mib, (u_int) mib_sz, kp, &len, NULL, 0) != -1)) { goto out; } @@ -2760,7 +2766,7 @@ jobmgr_reap_bulk(jmi, kev); } - if ((j = jobmgr_find_by_pid(jm, kev->ident, false))) { + if ((j = jobmgr_find_by_pid(jm, (pid_t) kev->ident, false))) { kev->udata = j; job_callback(j, kev); } @@ -2835,11 +2841,11 @@ case EVFILT_PROC: return job_callback_proc(j, kev->fflags); case EVFILT_TIMER: - return job_callback_timer(j, (void *)kev->ident); + return job_callback_timer(j, (void *) kev->ident); case EVFILT_VNODE: return semaphoreitem_callback(j, kev); case EVFILT_READ: - return job_callback_read(j, kev->ident); + return job_callback_read(j, (int) kev->ident); case EVFILT_MACHPORT: return (void)job_dispatch(j, true); default: @@ -3014,7 +3020,7 @@ glob_t g; short spflags = POSIX_SPAWN_SETEXEC; size_t binpref_out_cnt = 0; - int i; + size_t i; if (JOB_BOOTCACHE_HACK_CHECK(j)) { do_first_per_user_launchd_hack(); @@ -3885,10 +3891,17 @@ job_dispatch(j, false); } +struct cal_dict_walk { + job_t j; + struct tm tmptm; +}; + void calendarinterval_new_from_obj_dict_walk(launch_data_t obj, const char *key, void *context) { - struct tm *tmptm = context; + struct cal_dict_walk *cdw = context; + struct tm *tmptm = &cdw->tmptm; + job_t j = cdw->j; int64_t val; if (unlikely(LAUNCH_DATA_INTEGER != launch_data_get_type(obj))) { @@ -3899,16 +3912,18 @@ val = launch_data_get_integer(obj); - if (strcasecmp(key, LAUNCH_JOBKEY_CAL_MINUTE) == 0) { - tmptm->tm_min = val; + if (val < 0) { + job_log(j, LOG_WARNING, "The interval for key \"%s\" is less than zero.", key); + } else if (strcasecmp(key, LAUNCH_JOBKEY_CAL_MINUTE) == 0) { + tmptm->tm_min = (typeof(tmptm->tm_min)) val; } else if (strcasecmp(key, LAUNCH_JOBKEY_CAL_HOUR) == 0) { - tmptm->tm_hour = val; + tmptm->tm_hour = (typeof(tmptm->tm_hour)) val; } else if (strcasecmp(key, LAUNCH_JOBKEY_CAL_DAY) == 0) { - tmptm->tm_mday = val; + tmptm->tm_mday = (typeof(tmptm->tm_mday)) val; } else if (strcasecmp(key, LAUNCH_JOBKEY_CAL_WEEKDAY) == 0) { - tmptm->tm_wday = val; + tmptm->tm_wday = (typeof(tmptm->tm_wday)) val; } else if (strcasecmp(key, LAUNCH_JOBKEY_CAL_MONTH) == 0) { - tmptm->tm_mon = val; + tmptm->tm_mon = (typeof(tmptm->tm_mon)) val; tmptm->tm_mon -= 1; /* 4798263 cron compatibility */ } } @@ -3916,15 +3931,16 @@ bool calendarinterval_new_from_obj(job_t j, launch_data_t obj) { - struct tm tmptm; + struct cal_dict_walk cdw; - memset(&tmptm, 0, sizeof(0)); + cdw.j = j; + memset(&cdw.tmptm, 0, sizeof(0)); - tmptm.tm_min = -1; - tmptm.tm_hour = -1; - tmptm.tm_mday = -1; - tmptm.tm_wday = -1; - tmptm.tm_mon = -1; + cdw.tmptm.tm_min = -1; + cdw.tmptm.tm_hour = -1; + cdw.tmptm.tm_mday = -1; + cdw.tmptm.tm_wday = -1; + cdw.tmptm.tm_mon = -1; if (!job_assumes(j, obj != NULL)) { return false; @@ -3934,13 +3950,13 @@ return false; } - launch_data_dict_iterate(obj, calendarinterval_new_from_obj_dict_walk, &tmptm); + launch_data_dict_iterate(obj, calendarinterval_new_from_obj_dict_walk, &cdw); - if (unlikely(tmptm.tm_sec == -1)) { + if (unlikely(cdw.tmptm.tm_sec == -1)) { return false; } - return calendarinterval_new(j, &tmptm); + return calendarinterval_new(j, &cdw.tmptm); } bool @@ -4008,7 +4024,7 @@ } bool -socketgroup_new(job_t j, const char *name, int *fds, unsigned int fd_cnt, bool junkfds) +socketgroup_new(job_t j, const char *name, int *fds, size_t fd_cnt, bool junkfds) { struct socketgroup *sg = calloc(1, sizeof(struct socketgroup) + strlen(name) + 1); @@ -4086,7 +4102,7 @@ for (i = 0; i < sg->fd_cnt; i++) { job_assumes(j, kev[i].flags & EV_ERROR); - errno = kev[i].data; + errno = (typeof(errno)) kev[i].data; job_assumes(j, kev[i].data == 0); } } @@ -4230,7 +4246,7 @@ limititem_setup(launch_data_t obj, const char *key, void *context) { job_t j = context; - int i, limits_cnt = (sizeof(launchd_keys2limits) / sizeof(launchd_keys2limits[0])); + size_t i, limits_cnt = (sizeof(launchd_keys2limits) / sizeof(launchd_keys2limits[0])); rlim_t rl; if (launch_data_get_type(obj) != LAUNCH_DATA_INTEGER) { @@ -4581,14 +4597,15 @@ switch (launch_data_get_type(obj)) { case LAUNCH_DATA_INTEGER: - which_port = launch_data_get_integer(obj); + which_port = (int)launch_data_get_integer(obj); /* XXX we should bound check this... */ if (strcasecmp(key, LAUNCH_JOBKEY_MACH_TASKSPECIALPORT) == 0) { switch (which_port) { case TASK_KERNEL_PORT: case TASK_HOST_PORT: case TASK_NAME_PORT: case TASK_BOOTSTRAP_PORT: - /* I find it a little odd that zero isn't reserved in the header */ + /* I find it a little odd that zero isn't reserved in the header. + * Normally Mach is fairly good about this convention... */ case 0: job_log(ms->job, LOG_WARNING, "Tried to set a reserved task special port: %d", which_port); break; @@ -4885,7 +4902,7 @@ } if (trusted_fd) { - int dfd, lfd = strtol(trusted_fd, NULL, 10); + int dfd, lfd = (int) strtol(trusted_fd, NULL, 10); if ((dfd = dup(lfd)) >= 0) { jobmgr_assumes(jmr, runtime_close(dfd) != -1); @@ -4911,7 +4928,7 @@ } /* Sigh... at the moment, MIG has maxsize == sizeof(reply union) */ - mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); + mxmsgsz = (typeof(mxmsgsz)) sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; } @@ -5245,6 +5262,7 @@ char pidstr[100]; char *sample_args[] = { "sample", pidstr, "1", "-unsupportedShowArch", "-mayDie", "-file", logfile, NULL }; char *contents = NULL; + size_t contents_sz; int logfile_fd = -1; int console_fd = -1; int wstatus; @@ -5308,17 +5326,23 @@ goto out; } - contents = malloc(sb.st_size); + if (sizeof (size_t) == 4 && !job_assumes(j, !(sb.st_size & 0xffffffff00000000llu))) { + goto out; + } + contents_sz = (size_t) sb.st_size; + + contents = malloc(contents_sz); + if (!job_assumes(j, contents != NULL)) { goto out; } - if (!job_assumes(j, read(logfile_fd, contents, sb.st_size) == sb.st_size)) { + if (!job_assumes(j, read(logfile_fd, contents, contents_sz) == (ssize_t) contents_sz)) { goto out; } - job_assumes(j, write(console_fd, contents, sb.st_size) == sb.st_size); + job_assumes(j, write(console_fd, contents, contents_sz) == (ssize_t) contents_sz); out: if (contents) { @@ -6012,13 +6036,13 @@ j->ondemand = !inval; break; case VPROC_GSK_START_INTERVAL: - if ((uint64_t)inval > UINT32_MAX) { + if (inval > UINT32_MAX || inval < 0) { kr = 1; } else if (inval) { if (j->start_interval == 0) { runtime_add_weak_ref(); } - j->start_interval = inval; + j->start_interval = (typeof(j->start_interval)) inval; job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, j->start_interval, j) != -1); } else if (j->start_interval) { job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); @@ -6029,20 +6053,33 @@ } break; case VPROC_GSK_IDLE_TIMEOUT: - if ((unsigned int)inval > 0) { - j->timeout = inval; + if (inval < 0 || inval > UINT32_MAX) { + kr = 1; + } else { + j->timeout = (typeof(j->timeout)) inval; } break; case VPROC_GSK_EXIT_TIMEOUT: - if ((unsigned int)inval > 0) { - j->exit_timeout = inval; + if (inval < 0 || inval > UINT32_MAX) { + kr = 1; + } else { + j->exit_timeout = (typeof(j->exit_timeout)) inval; } break; case VPROC_GSK_GLOBAL_LOG_MASK: - runtime_setlogmask(inval); + if (inval < 0 || inval > UINT32_MAX) { + kr = 1; + } else { + runtime_setlogmask((int) inval); + } break; case VPROC_GSK_GLOBAL_UMASK: - umask(inval); + launchd_assert(sizeof (mode_t) == 2); + if (inval < 0 || inval > UINT16_MAX) { + kr = 1; + } else { + umask((mode_t) inval); + } break; case 0: break; @@ -7073,7 +7110,7 @@ } } else { target_j->deny_unknown_mslookups = !(flags & BOOTSTRAP_ALLOW_LOOKUP); - target_j->deny_job_creation = (bool)(flags & BOOTSTRAP_DENY_JOB_CREATION); + target_j->deny_job_creation = flags & BOOTSTRAP_DENY_JOB_CREATION; } return 0; @@ -7307,7 +7344,7 @@ int r, i, found, returned; do { - returned = getfsstat(buf, sizeof(buf), MNT_NOWAIT); + returned = getfsstat(buf, (int) sizeof(buf), MNT_NOWAIT); found = 0; if (!launchd_assumes(returned != -1)) { Modified: trunk/launchd/src/launchproxy.c =================================================================== --- trunk/launchd/src/launchproxy.c 2008-05-28 20:33:08 UTC (rev 23639) +++ trunk/launchd/src/launchproxy.c 2008-06-04 21:57:47 UTC (rev 23640) @@ -81,7 +81,7 @@ { struct timespec timeout = { 10, 0 }; struct sockaddr_storage ss; - socklen_t slen = sizeof(ss); + socklen_t slen = (socklen_t)sizeof ss; struct kevent kev; int r, ec = EXIT_FAILURE; launch_data_t tmp, resp, msg = launch_data_alloc(LAUNCH_DATA_STRING); @@ -143,17 +143,17 @@ } if (w) { - dup2(kev.ident, STDIN_FILENO); + dup2((int)kev.ident, STDIN_FILENO); if (dupstdout) - dup2(kev.ident, STDOUT_FILENO); + dup2((int)kev.ident, STDOUT_FILENO); if (dupstderr) - dup2(kev.ident, STDERR_FILENO); + dup2((int)kev.ident, STDERR_FILENO); execv(prog, argv + 1); syslog(LOG_ERR, "execv(): %m"); exit(EXIT_FAILURE); } - if ((r = accept(kev.ident, (struct sockaddr *)&ss, &slen)) == -1) { + if ((r = accept((int)kev.ident, (struct sockaddr *)&ss, &slen)) == -1) { if (errno == EWOULDBLOCK) continue; syslog(LOG_DEBUG, "accept(): %m"); @@ -165,8 +165,8 @@ int gni_r; gni_r = getnameinfo((struct sockaddr *)&ss, slen, - fromhost, sizeof(fromhost), - fromport, sizeof(fromport), + fromhost, (socklen_t) sizeof fromhost, + fromport, (socklen_t) sizeof fromport, NI_NUMERICHOST | NI_NUMERICSERV); if (gni_r) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080604/19fa9de5/attachment-0001.htm From source_changes at macosforge.org Fri Jun 6 08:48:42 2008 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Fri, 6 Jun 2008 08:48:42 -0700 (PDT) Subject: [launchd-changes] [23641] trunk/launchd/src/launchd.plist.5 Message-ID: <20080606154842.1B655173F88A@beta.macosforge.org> Revision: 23641 http://trac.macosforge.org/projects/launchd/changeset/23641 Author: zarzycki at apple.com Date: 2008-06-06 08:48:42 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Make a note about kern.hostname. Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2008-06-04 21:57:47 UTC (rev 23640) +++ trunk/launchd/src/launchd.plist.5 2008-06-06 15:48:42 UTC (rev 23641) @@ -99,9 +99,13 @@ is called on behalf of the job, and the result is passed via the standard in/out/error descriptors. .El .It Sy LimitLoadToHosts -This configuration file only applies to the hosts listed with this key. +This configuration file only applies to the hosts listed with this key. Note: One should set kern.hostname in +.Xr sysctl.conf 5 +for this feature to work reliably. .It Sy LimitLoadFromHosts -This configuration file only applies to hosts NOT listed with this key. +This configuration file only applies to hosts NOT listed with this key. Note: One should set kern.hostname in +.Xr sysctl.conf 5 +for this feature to work reliably. .It Sy LimitLoadToSessionType This configuration file only applies to sessions of the type specified. This key is used in concert with the -S flag to -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080606/c891376a/attachment.htm