diff options
| author | Ned T. Crigler <crigler@gmail.com> | 2025-06-16 20:06:28 -0700 |
|---|---|---|
| committer | Ned T. Crigler <crigler@gmail.com> | 2025-06-17 08:15:03 -0700 |
| commit | edb19a321c4e15e660426acb68581578a67c5576 (patch) | |
| tree | 97e6bdd280b5b91bacea7f32e46b64b8ec84cf9c /master.c | |
| parent | 5af437fe9c99198287eadbc877cef2a0c3202a3c (diff) | |
Move umask(omask) call after bind
Just wrapping the socket system call with umask doesn't work.
Diffstat (limited to 'master.c')
| -rw-r--r-- | master.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -193,16 +193,20 @@ create_socket(char *name) omask = umask(077); s = socket(PF_UNIX, SOCK_STREAM, 0); - umask(omask); /* umask always succeeds, errno is untouched. */ if (s < 0) + { + umask(omask); /* umask always succeeds, errno is untouched. */ return -1; + } sockun.sun_family = AF_UNIX; strcpy(sockun.sun_path, name); if (bind(s, (struct sockaddr*)&sockun, sizeof(sockun)) < 0) { + umask(omask); /* umask always succeeds, errno is untouched. */ close(s); return -1; } + umask(omask); /* umask always succeeds, errno is untouched. */ if (listen(s, 128) < 0) { close(s); @@ -213,7 +217,7 @@ create_socket(char *name) close(s); return -1; } - /* chmod it to prevent any suprises */ + /* chmod it to prevent any surprises */ if (chmod(name, 0600) < 0) { close(s); |
