-/* $OpenBSD: cmd-set-option.c,v 1.112 2017/02/16 10:53:25 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.113 2017/04/22 06:13:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
enum options_table_scope scope;
struct options *oo;
struct options_entry *parent, *o;
- const char *name, *value, *target;
+ char *name;
+ const char *value, *target;
int window, idx, already, error, ambiguous;
char *cause;
return (CMD_RETURN_NORMAL);
cmdq_error(item, "%s", cause);
free(cause);
- return (CMD_RETURN_ERROR);
+ goto fail;
}
/* Which table should this option go into? */
cmdq_error(item, "no such session: %s", target);
else
cmdq_error(item, "no current session");
- return (CMD_RETURN_ERROR);
+ goto fail;
} else
oo = s->options;
} else if (scope == OPTIONS_TABLE_WINDOW) {
cmdq_error(item, "no such window: %s", target);
else
cmdq_error(item, "no current window");
- return (CMD_RETURN_ERROR);
+ goto fail;
} else
oo = wl->window->options;
}
if (idx != -1) {
if (*name == '@' || options_array_size(parent, NULL) == -1) {
cmdq_error(item, "not an array: %s", args->argv[0]);
- return (CMD_RETURN_ERROR);
+ goto fail;
}
}
if (args_has(args, 'q'))
return (CMD_RETURN_NORMAL);
cmdq_error(item, "already set: %s", args->argv[0]);
- return (CMD_RETURN_ERROR);
+ goto fail;
}
}
/* Change the option. */
if (args_has(args, 'u')) {
if (o == NULL)
- return (CMD_RETURN_NORMAL);
+ goto fail;
if (idx == -1) {
if (oo == global_options ||
oo == global_s_options ||
} else if (*name == '@') {
if (value == NULL) {
cmdq_error(item, "empty value");
- return (CMD_RETURN_ERROR);
+ goto fail;
}
options_set_string(oo, name, append, "%s", value);
} else if (idx == -1 && options_array_size(parent, NULL) == -1) {
error = cmd_set_option_set(self, item, oo, parent, value);
if (error != 0)
- return (CMD_RETURN_ERROR);
+ goto fail;
} else {
if (value == NULL) {
cmdq_error(item, "empty value");
- return (CMD_RETURN_ERROR);
+ goto fail;
}
if (o == NULL)
o = options_empty(oo, options_table_entry(parent));
options_array_assign(o, value);
} else if (options_array_set(o, idx, value, append) != 0) {
cmdq_error(item, "invalid index: %s", args->argv[0]);
- return (CMD_RETURN_ERROR);
+ goto fail;
}
}
server_redraw_client(c);
}
+ free(name);
return (CMD_RETURN_NORMAL);
+
+fail:
+ free(name);
+ return (CMD_RETURN_ERROR);
}
static int
-/* $OpenBSD: server.c,v 1.169 2017/04/21 20:26:34 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.170 2017/04/22 06:13:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
return (-1);
mask = umask(S_IXUSR|S_IXGRP|S_IRWXO);
- if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1)
+ if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {
+ close(fd);
return (-1);
+ }
umask(mask);
- if (listen(fd, 128) == -1)
+ if (listen(fd, 128) == -1) {
+ close(fd);
return (-1);
+ }
setblocking(fd, 0);
return (fd);