launch_data_t r = data + *data_offset;
size_t i, tmpcnt;
+ //Check for integer underflow
+ if (data_size < *data_offset)
+ return NULL;
+
if ((data_size - *data_offset) < sizeof(struct _launch_data))
return NULL;
*data_offset += sizeof(struct _launch_data);
case LAUNCH_DATA_DICTIONARY:
case LAUNCH_DATA_ARRAY:
tmpcnt = big2wire(r->_array_cnt);
+
+ //Check for integer overflows
+ if (tmpcnt > SIZE_MAX / sizeof(uint64_t)) {
+ errno = EAGAIN;
+ return NULL;
+ }
+
if ((data_size - *data_offset) < (tmpcnt * sizeof(uint64_t))) {
errno = EAGAIN;
return NULL;
if (j->mgr->session_initialized) {
job_log(j, LOG_ERR, "Tried to initialize an already setup session!");
kr = BOOTSTRAP_NOT_PRIVILEGED;
+ return kr;
} else if (strcmp(session_type, VPROCMGR_SESSION_LOGINWINDOW) == 0) {
jobmgr_t jmi;
break;
}
+ if (lm_walk->obj_sz < sizeof(struct logmsg_s)) {
+ launchd_syslog(LOG_WARNING, "Received bytes %llu are less than expected bytes %lu.", lm_walk->obj_sz, sizeof(struct logmsg_s));
+ break;
+ }
+
if (!(lm = malloc(lm_walk->obj_sz))) {
launchd_syslog(LOG_WARNING, "Failed to allocate %llu bytes for log message with %u bytes left in forwarded data. Ignoring remaining messages.", lm_walk->obj_sz, data_left);
break;