Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at file-dotlock.c:120

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

read_local_pid

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/file-dotlock.c)expand/collapse
Show more  
 91  static pid_t read_local_pid(const char *lock_path)
 92  {
 93          char buf[512], *host;
 94          int fd;
 95          ssize_t ret;
 96          pid_t pid;
 97   
 98          fd = open(lock_path, O_RDONLY);
 99          if (fd == -1)
 100                  return -1; /* ignore the actual error */
 101   
 102          /* read line */
 103          ret = read(fd, buf, sizeof(buf)-1);
 104          (void)close(fd);
 105          if (ret <= 0)
 106                  return -1;
 107   
 108          /* fix the string */
 109          if (buf[ret-1] == '\n')
 110                  ret--;
 111          buf[ret] = '\0';
 112   
 113          /* it should contain pid:host */
 114          host = strchr(buf, ':');
 115          if (host == NULL)
 116                  return -1;
 117          *host++ = '\0';
 118   
 119          /* host must be ours */
 120          if (strcmp(host, my_hostname) != 0)
 121                  return -1;
 122   
 123          if (!is_numeric(buf, '\0'))
 124                  return -1;
 125          pid = (pid_t)strtoul(buf, NULL, 0);
 126          if (pid <= 0)
 127                  return -1;
 128          return pid;
 129  }
Show more  




Change Warning 7064.24425 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: