Text   |  XML   |  ReML   |   Visible Warnings:

Leak  at unix-socket-create.c:17

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

unix_socket_create

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/unix-socket-create.c)expand/collapse
Show more  
 10  int unix_socket_create(const char *path, int mode,
 11                         uid_t uid, gid_t gid, int backlog)
 12  {
 13          mode_t old_umask;
 14          int fd;
 15   
 16          old_umask = umask(0777 ^ mode);
 17[+]         fd = net_listen_unix_unlink_stale(path, backlog);
expand/collapse

net_listen_unix_unlink_stale

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/network.c)expand/collapse
Show more  
 398  int net_listen_unix_unlink_stale(const char *path, int backlog)
 399  {
 400          unsigned int i = 0;
 401          int fd;
 402   
 403[+]         while ((fd = net_listen_unix(path, backlog)) == -1) {
expand/collapse

net_listen_unix

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/network.c)expand/collapse
Show more  
 358  int net_listen_unix(const char *path, int backlog)
 359  {
 360          union {
 361                  struct sockaddr sa;
 362                  struct sockaddr_un un;
 363          } sa;
 364          int fd;
 365   
 366          memset(&sa, 0, sizeof(sa));
 367          sa.un.sun_family = AF_UNIX;
 368          if (i_strocpy(sa.un.sun_path, path, sizeof(sa.un.sun_path)) < 0) {
 369                  /* too long path */
 370                  errno = EINVAL;
 371                  return -1;
 372          }
 373   
 374          /* create the socket */
 375          fd = socket(PF_UNIX, SOCK_STREAM, 0);
 376          if (fd == -1) {
 377                  i_error("socket() failed: %m");
 378                  return -1;
 379          }
 380   
 381          /* bind */
 382          if (bind(fd, &sa.sa, sizeof(sa)) < 0) {
 383                  if (errno != EADDRINUSE)
 384                          i_error("bind(%s) failed: %m", path);
 385          } else {
 386                  /* start listening */
 387                  if (listen(fd, backlog) == 0)
 388                          return fd;
Show more  
 404                  if (errno != EADDRINUSE || ++i == 2)
 405                          return -1;
 406   
 407                  /* see if it really exists */
 408                  fd = net_connect_unix(path);
 409                  if (fd != -1 || errno != ECONNREFUSED) {
 410                          if (fd != -1) (void)close(fd);
 411                          errno = EADDRINUSE;
 412                          return -1;
 413                  }
 414   
 415                  /* delete and try again */
 416                  if (unlink(path) < 0 && errno != ENOENT) {
 417                          i_error("unlink(%s) failed: %m", path);
 418                          errno = EADDRINUSE;
 419                          return -1;
 420                  }
 421          }
 422          return fd;
Show more  
 18          umask(old_umask);
 19   
 20          if (fd < 0) {
 21                  i_error("net_listen_unix(%s) failed: %m", path);
 22                  return -1;
 23          }
 24   
 25          if (uid != (uid_t)-1 || gid != (gid_t)-1) {
 26                  /* set correct permissions */
 27                  if (chown(path, uid, gid) < 0) {
 28                          i_error("chown(%s, %s, %s) failed: %m",
 29                                  path, dec2str(uid), dec2str(gid));
 30                          return -1;
Show more  




Change Warning 7135.24610 : Leak

Priority:
State:
Finding:
Owner:
Note: