(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/auth/db-passwd-file.c) |
| |
| 23 | | | static void passwd_file_add(struct passwd_file *pw, const char *username, |
| 24 | | | const char *pass, const char *const *args) |
| 25 | | | { |
| 26 | | | |
| 27 | | | struct passwd_user *pu; |
| 28 | | | const char * = 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);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/mempool.h |
| |
84 | #define p_new(pool, type, count) \ |
85 | ((type *) p_malloc(pool, sizeof(type) * (count))) |
| |
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/mempool.h |
| |
87 | #define p_malloc(pool, size) (pool)->v->malloc(pool, size) |
| |
|
| 39 | | | user = p_strdup(pw->pool, username); |
Ignored Return Value
The return value of p_strdup() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of p_strdup() is checked 98% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt p_strdup() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 40 | | | |
| 41 | | | len = pass == NULL ? 0 : strlen(pass); |
Event 2:
pass == (void *)0 evaluates to false.
hide
|
|
| 42 | | | if (len > 4 && pass[0] != '{' && pass[0] != '$' && |
| 43 | | | pass[len-1] == ']' && pass[len-4] == '[') { |
| 44 | | | |
| 45 | | | |
| 46 | | | |
| 47 | | | int num = (pass[len-3] - '0') * 10 + (pass[len-2] - '0'); |
| 48 | | | |
| 49 | | | pass = t_strndup(pass, len-4); |
| 50 | | | if (num == 34) { |
Event 4:
Taking false branch. num == 34 evaluates to false.
hide
|
|
| 51 | | | pu->password = p_strconcat(pw->pool, "{PLAIN-MD5}", |
| 52 | | | pass, NULL); |
| 53 | | | } else if (num == 56) { |
Event 5:
Taking false branch. num == 56 evaluates to false.
hide
|
|
| 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) |
Event 6:
Taking false branch. *args == (void *)0 evaluates to false.
hide
|
|
| 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) { |
Event 8:
Taking false branch. *args == (void *)0 evaluates to false.
hide
|
|
| 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 | | | |
| 105 | | | if (*args != NULL) |
| 106 | | | args++; |
| 107 | | | |
| 108 | | | |
| 109 | | | if (*args != NULL) { |
| 110 | | | if (pw->db->userdb) |
| 111 | | | pu->home = p_strdup_empty(pw->pool, *args); |
| 112 | | | args++; |
| 113 | | | } |
| 114 | | | |
| 115 | | | |
| 116 | | | if (*args != NULL) |
| 117 | | | args++; |
| 118 | | | |
| 119 | | | if (*args != NULL && **args == '\0') { |
| 120 | | | |
| 121 | | | |
| 122 | | | args++; |
| 123 | | | if (*args != NULL && **args != '\0' && pw->db->userdb) { |
| 124 | | | = |
| 125 | | | t_strconcat("userdb_mail=", |
| 126 | | | t_strarray_join(args, ":"), NULL); |
| 127 | | | } |
| 128 | | | } else if (*args != NULL) { |
| 129 | | | |
| 130 | | | |
| 131 | | | = t_strarray_join(args, ":"); |
| 132 | | | } |
| 133 | | | |
| 134 | | | if ( != NULL) { |
| 135 | | | pu-> = |
| 136 | | | p_strsplit_spaces(pw->pool, , " "); |
| 137 | | | } |
| 138 | | | |
| 139 | | | hash_table_insert(pw->users, user, pu); |
| 140 | | | } |
| |