}
handler->ramdisks[i] = dev;
- i = handler->n_ramdisks++;
+ handler->n_ramdisks++;
}
struct ramdisk_device *device_handler_get_ramdisk(
{
struct status *status;
char *hash;
- int rc;
+ int rc = 0;
status = talloc_zero(client, struct status);
struct client *client = arg;
struct config *config;
char *url;
- int rc;
+ int rc = 0;
message = pb_protocol_read_message(client, client->fd);
talloc_free(status);
}
}
- return 0;
+ return rc;
}
switch (message->action) {
break;
}
- rc = discover_server_handle_auth_message(client, auth_msg);
+ discover_server_handle_auth_message(client, auth_msg);
talloc_free(auth_msg);
break;
default:
/* Allow all clients to communicate on this socket */
group = getgrnam("petitgroup");
if (group) {
- chown(PB_SOCKET_PATH, 0, group->gr_gid);
- chmod(PB_SOCKET_PATH, 0660);
+ if (chown(PB_SOCKET_PATH, 0, group->gr_gid))
+ pb_log_fn("Error setting socket ownership: %m\n");
+ errno = 0;
+ if (chmod(PB_SOCKET_PATH, 0660))
+ pb_log_fn("Error setting socket permissions: %m\n");
}
if (listen(server->socket, 8)) {
sep = memchr(buf, '=', param_len);
if (!sep) {
name_len = param_len;
- value_len = 0;
param->value = "";
} else {
name_len = sep - buf;
if (!rc) {
rc = parse_buf_to_env(script, buf, len);
+ if (rc)
+ pb_debug_fn("Failed to set env\n");
talloc_free(buf);
}
}
/* we may have allocated an extra argv element but not populated it */
- if (!argv->argv[argv->argc - 1])
+ if (argv->argv && !argv->argv[argv->argc - 1])
argv->argc--;
}
{
struct discover_boot_option *opt, *tmp;
+ if (!script)
+ return;
+
init_env(script);
statements_execute(script, script->statements);
return -1;
}
ifconf->static_config.gateway = gatewaystr;
- i += ipsize;
}
ifconf->override = true;
result->status = LOAD_OK;
}
- task->async_cb(task->result, task->async_data);
+ if (task->async_cb)
+ task->async_cb(task->result, task->async_data);
}
static void load_url_async_start_pending(struct load_task *task, int flags)
continue;
}
+ if (!name) {
+ pb_debug_fn("missing name from conf_get_pair\n");
+ continue;
+ }
+
/* All other parameters require a value */
if (!value) {
- pb_debug("%s: '%s' missing value\n", __func__, name);
+ pb_debug_fn("'%s' missing value\n", name);
continue;
}
break;
case EVENT_ACTION_URL:
result = user_event_url(uev, event);
- goto out;
+ break;
case EVENT_ACTION_DHCP:
result = user_event_dhcp(uev, event);
- goto out;
+ break;
case EVENT_ACTION_BOOT:
result = user_event_boot(uev, event);
break;
result = user_event_plugin(uev, event);
break;
default:
+ result = -1;
break;
}
+ if (result)
+ pb_log_fn("failed to handle action %d\n", event->action);
+
/* user_event_url() and user_event_dhcp() will steal the event context,
* but all others still need to free */
- talloc_free(event);
-out:
+ if (talloc_parent(event) == uev)
+ talloc_free(event);
return;
}
}
/* Don't allow events from non-priviledged users */
- chown(PBOOT_USER_EVENT_SOCKET, 0, 0);
- chmod(PBOOT_USER_EVENT_SOCKET, 0660);
+ if (chown(PBOOT_USER_EVENT_SOCKET, 0, 0))
+ pb_log_fn("Error setting socket ownership: %m\n");
+ errno = 0;
+ if (chmod(PBOOT_USER_EVENT_SOCKET, 0660))
+ pb_log_fn("Error setting socket permissions: %m\n");
waiter_register_io(waitset, uev->socket, WAIT_IN,
user_event_process, uev);
/* Then start the new image. */
opt = state_start_new_option(conf, state);
+ if (!opt)
+ pb_debug_fn("new opt is NULL\n");
state->boot_image = talloc_strdup(state, value);
/* Then start the new image. */
opt = state_start_new_option(conf, state);
+ if (!opt)
+ pb_debug_fn("new opt is NULL\n");
if (*value == '/') {
state->boot_image = talloc_strdup(state, value);
struct config *dest;
unsigned int i;
+ if (!src)
+ return NULL;
+
dest = talloc_zero(ctx, struct config);
dest->autoboot_enabled = src->autoboot_enabled;
dest->autoboot_timeout_sec = src->autoboot_timeout_sec;
dest->allow_writes = src->allow_writes;
dest->n_consoles = src->n_consoles;
- if (src->consoles)
+ if (src->consoles) {
dest->consoles = talloc_array(dest, char *, src->n_consoles);
- for (i = 0; i < src->n_consoles && src->n_consoles; i++)
- dest->consoles[i] = talloc_strdup(dest->consoles,
+ for (i = 0; i < src->n_consoles && src->n_consoles; i++)
+ if (src->consoles[i])
+ dest->consoles[i] = talloc_strdup(
+ dest->consoles,
src->consoles[i]);
+ }
if (src->boot_console)
dest->boot_console = talloc_strdup(dest, src->boot_console);
{
int len = 0;
+ if (!pos)
+ return 0;
+
if (str)
len = strlen(str);
*(uint32_t *)pos = __cpu_to_be32(len);
pos += sizeof(uint32_t);
- memcpy(pos, str, len);
+ if (str)
+ memcpy(pos, str, len);
return len + sizeof(uint32_t);
}
pos += pb_protocol_serialise_string(pos, dev->icon_file);
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_boot_option(const struct boot_option *opt,
pos += 4;
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_boot_command(const struct boot_command *boot,
pos += pb_protocol_serialise_string(pos, boot->console);
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_boot_status(const struct status *status,
pos += sizeof(bool);
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
pos += HWADDR_SIZE;
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
static int pb_protocol_serialise_config_interface(char *buf,
pos += pb_protocol_serialise_string(pos, config->lang);
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_url(const char *url, char *buf, int buf_len)
pos += pb_protocol_serialise_string(pos, url);
assert(pos <=buf+buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_plugin_option(const struct plugin_option *opt,
pos += pb_protocol_serialise_string(pos, opt->executables[i]);
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_temp_autoboot(const struct autoboot_option *opt,
pos += pb_protocol_serialise_string(pos, opt->uuid);
}
- (void)buf_len;
+ assert(pos <= buf + buf_len);
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_serialise_authenticate(struct auth_message *msg,
};
assert(pos <= buf + buf_len);
- (void)buf_len;
- return 0;
+ return (pos <= buf + buf_len) ? 0 : -1;
}
int pb_protocol_write_message(int fd, struct pb_protocol_message *message)
if (read_u32(&pos, &len, &opt->type))
return -1;
- rc = 0;
+ rc = (pos <= message->payload + message->payload_len) ? 0 : -1;
out:
return rc;
struct pmenu_item *item;
unsigned int j;
result = set_menu_items(cui->main->ncm, NULL);
- for (j = 0 ; j < cui->main->item_count; j++) {
+ if (result)
+ pb_log_fn("unset_menu_items failed: %d\n", result);
+ for (j = 0 ; j < cui->main->item_count && !result; j++) {
item = item_userptr(cui->main->items[j]);
if (item->on_execute != menu_plugin_execute)
continue;
int main(void)
{
struct offb_ctx *ctx;
- int rc;
+ int rc = 0;
ctx = talloc_zero(NULL, struct offb_ctx);