Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at db-passwd-file.c:39

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

passwd_file_add

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/auth/db-passwd-file.c)expand/collapse
Show more  
 23  static void passwd_file_add(struct passwd_file *pw, const char *username,
 24                              const char *pass, const char *const *args)
 25  {
 26          /* args = uid, gid, user info, home dir, shell, extra_fields */
 27          struct passwd_user *pu;
 28          const char *extra_fields = NULL;
 29          char *user;
 30          size_t len;
 31   
 32          if (hash_table_lookup(pw->users, username) != NULL) {
 33                  i_error("passwd-file %s: User %s exists more than once",
 34                          pw->path, username);
 35                  return;
 36          }
 37   
 38          pu = p_new(pw->pool, struct passwd_user, 1);
 39          user = p_strdup(pw->pool, username);
 40   
 41          len = pass == NULL ? 0 : strlen(pass);
 42          if (len > 4 && pass[0] != '{' && pass[0] != '$' &&
 43              pass[len-1] == ']' && pass[len-4] == '[') {
 44                  /* password[type] - we're being libpam-pwdfile compatible 
 45                     here. it uses 13 = DES and 34 = MD5. For backwards
 46                     comaptibility with ourself, we have also 56 = Digest-MD5. */
 47                  int num = (pass[len-3] - '0') * 10 + (pass[len-2] - '0');
 48   
 49                  pass = t_strndup(pass, len-4);
 50                  if (num == 34) {
 51                          pu->password = p_strconcat(pw->pool, "{PLAIN-MD5}",
 52                                                     pass, NULL);
 53                  } else if (num == 56) {
 54                          pu->password = p_strconcat(pw->pool, "{DIGEST-MD5}",
 55                                                     pass, NULL);
 56                          if (strlen(pu->password) != 32 + 12) {
 57                                  i_error("passwd-file %s: User %s "
 58                                          "has invalid password",
 59                                          pw->path, username);
 60                                  return;
 61                          }
 62                  } else {
 63                          pu->password = p_strconcat(pw->pool, "{CRYPT}",
 64                                                     pass, NULL);
 65                  }
 66          } else {
 67                  pu->password = p_strdup(pw->pool, pass);
 68          }
 69   
 70          pu->uid = (uid_t)-1;
 71          pu->gid = (gid_t)-1;
 72   
 73          if (*args == NULL)
 74                  ;
 75          else if (!pw->db->userdb || **args == '\0') {
 76                  args++;
 77          } else {
 78                  pu->uid = userdb_parse_uid(NULL, *args);
 79                  if (pu->uid == 0 || pu->uid == (uid_t)-1) {
 80                          i_error("passwd-file %s: User %s has invalid UID '%s'",
 81                                  pw->path, username, *args);
 82                          return;
 83                  }
 84                  args++;
 85          }
 86   
 87          if (*args == NULL) {
 88                  if (pw->db->userdb) {
 89                          i_error("passwd-file %s: User %s is missing "
 90                                  "userdb info", pw->path, username);
 91                  }
 92          } else if (!pw->db->userdb || **args == '\0')
 93                  args++;
 94          else {
 95                  pu->gid = userdb_parse_gid(NULL, *args);
 96                  if (pu->gid == 0 || pu->gid == (gid_t)-1) {
 97                          i_error("passwd-file %s: User %s has invalid GID '%s'",
 98                                  pw->path, username, *args);
 99                          return;
 100                  }
 101                  args++;
 102          }
 103   
 104          /* user info */
 105          if (*args != NULL)
 106                  args++;
 107   
 108          /* home */
 109          if (*args != NULL) {
 110                  if (pw->db->userdb)
 111                          pu->home = p_strdup_empty(pw->pool, *args);
 112                  args++;
 113          }
 114   
 115          /* shell */
 116          if (*args != NULL)
 117                  args++;
 118   
 119          if (*args != NULL && **args == '\0') {
 120                  /* old format, this field is empty and next field may
 121                     contain MAIL */
 122                  args++;
 123                  if (*args != NULL && **args != '\0' && pw->db->userdb) {
 124                          extra_fields =
 125                                  t_strconcat("userdb_mail=",
 126                                              t_strarray_join(args, ":"), NULL);
 127                  }
 128          } else if (*args != NULL) {
 129                  /* new format, contains a space separated list of
 130                     extra fields */
 131                  extra_fields = t_strarray_join(args, ":");
 132          }
 133   
 134          if (extra_fields != NULL) {
 135                  pu->extra_fields =
 136                          p_strsplit_spaces(pw->pool, extra_fields, " ");
 137          }
 138   
 139          hash_table_insert(pw->users, user, pu);
 140  }
Show more  




Change Warning 8177.26086 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: