Download raw body.
gotsh: simplify unix_socket_path handling
noticed while was investigating that gotd issue. there's no need to
copy the path to a temporary buffer, and if it's too long we will fail
anyway right before connect.
ok?
diff /home/op/w/got
commit - 87724ba023ff5063a868e68ac90b991ae1cf7ec8
path + /home/op/w/got
blob - fb5f331b5c32503b2fe1e1c4de73a8af9959be9d
file + gotsh/gotsh.c
--- gotsh/gotsh.c
+++ gotsh/gotsh.c
@@ -63,8 +63,7 @@ main(int argc, char *argv[])
main(int argc, char *argv[])
{
const struct got_error *error;
- char unix_socket_path[PATH_MAX];
- char *unix_socket_path_env = getenv("GOTD_UNIX_SOCKET");
+ const char *unix_socket_path;
int gotd_sock = -1;
struct sockaddr_un sun;
char *gitcmd = NULL, *command = NULL, *repo_path = NULL;
@@ -90,14 +89,9 @@ main(int argc, char *argv[])
if (error)
goto done;
- if (unix_socket_path_env) {
- if (strlcpy(unix_socket_path, unix_socket_path_env,
- sizeof(unix_socket_path)) >= sizeof(unix_socket_path))
- errx(1, "gotd socket path too long");
- } else {
- strlcpy(unix_socket_path, GOTD_UNIX_SOCKET,
- sizeof(unix_socket_path));
- }
+ unix_socket_path = getenv("GOTD_UNIX_SOCKET");
+ if (unix_socket_path == NULL)
+ unix_socket_path = GOTD_UNIX_SOCKET;
error = apply_unveil(unix_socket_path);
if (error)
gotsh: simplify unix_socket_path handling