Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at eacces-error.c:59

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

test_access

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/eacces-error.c)expand/collapse
Show more  
 29  static int test_access(const char *path, int mode, string_t *errmsg)
 30  {
 31          struct stat st;
 32   
 33          if (getuid() == geteuid()) {
 34                  if (access(path, mode) == 0)
 35                          return 0;
 36   
 37                  if (errno != EACCES) {
 38                          str_printfa(errmsg, " access(%s, %d) failed: %m",
 39                                      path, mode);
 40                  }
 41                  return -1;
 42          }  
 43   
 44          /* access() uses real uid, not effective uid.
 45             we'll have to do these checks manually. */
 46          switch (mode) {
 47          case X_OK:
 48                  if (stat(t_strconcat(path, "/test", NULL), &st) == 0)
 49                          return 0;
 50                  if (errno == ENOENT || errno == ENOTDIR)
 51                          return 0;
 52                  if (errno != EACCES)
 53                          str_printfa(errmsg, " stat(%s/test) failed: %m", path);
 54                  return -1;
 55          case R_OK:
 56                  mode = 04;
 57                  break;
 58          case W_OK:
 59                  mode = 02;
 60                  break;
 61          default:
 62                  i_unreached();
 63          }
 64   
 65          if (stat(path, &st) < 0) {
 66                  str_printfa(errmsg, " stat(%s) failed: %m", path);
 67                  return -1;
 68          }
 69   
 70          if (st.st_uid == geteuid())
 71                  st.st_mode = (st.st_mode & 0700) >> 6;
 72          else if (is_in_group(st.st_gid))
 73                  st.st_mode = (st.st_mode & 0070) >> 3;
 74          else 
 75                  st.st_mode = (st.st_mode & 0007);
 76   
 77          if ((st.st_mode & mode) != 0)
 78                  return 0;
 79          errno = EACCES;
 80          return -1;
 81  }
Show more  




Change Warning 7042.24732 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: