Text   |  XML   |  ReML   |   Visible Warnings:

Uninitialized Variable  at password-scheme.c:178

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

main

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/util/dovecotpw.c)expand/collapse
Show more  
 36  int main(int argc, char *argv[])
 37  {
 38          const char *hash = NULL;
 39          const char *user = NULL;
 40          char *scheme = NULL;
 41          char *plaintext = NULL;
 42          int ch, lflag = 0, Vflag = 0;
 43   
 44          lib_init();
 45          random_init();
 46[+]         password_schemes_init();
 47           
 48          while ((ch = getopt(argc, argv, "lp:s:u:V")) != -1) {
 49                  switch (ch) {
 50                  case 'l':
 51                          lflag = 1;
 52                          break;
 53                  case 'p':
 54                          plaintext = i_strdup(optarg);
 55                          safe_memset(optarg, 0, strlen(optarg));
 56                          break;
 57                  case 's':
 58                          scheme = i_strdup(optarg);
 59                          break;
 60                  case 'u':
 61                          user = i_strdup(optarg);
 62                          break;
 63                  case 'V':
 64                          Vflag = 1;
 65                          break;
 66                  case '?':
 67                  default:
 68                          usage(basename(*argv));
 69                  }
 70          }
 71   
 72          if (lflag) {
 73                  const struct password_scheme *const *schemes;
 74                  unsigned int i, count;
 75   
 76                  schemes = array_get(&password_schemes, &count);
 77                  for (i = 0; i < count; i++)
 78                          printf("%s ", schemes[i]->name);
 79                  printf("\n");
 80                  exit(0);
 81          }
 82   
 83          if (argc != optind)
 84                  usage(basename(*argv));
 85   
 86          if (scheme == NULL)
 87                  scheme = i_strdup(DEFAULT_SCHEME);
 88          else {
 89                  char *c;
 90                  for (c = scheme; *c != '\0'; c++)
 91                          *c = i_toupper(*c);
 92          }
 93   
 94   
 95          while (plaintext == NULL) {
 96                  char *check;
 97                  static int lives = 3;
 98   
 99                  plaintext = i_strdup(getpass("Enter new password: "));
 100                  check = i_strdup(getpass("Retype new password: "));
 101                  if (strcmp(plaintext, check) != 0) {
 102                          fprintf(stderr, "Passwords don't match!\n");
 103                          if (--lives == 0)
 104                                  exit(1);
 105                          safe_memset(plaintext, 0, strlen(plaintext));
 106                          safe_memset(check, 0, strlen(check));
 107                          i_free(plaintext);
 108                          i_free(check);
 109                          plaintext = NULL;
 110                  }
 111          }
 112   
 113[+]         if (!password_generate_encoded(plaintext, user, scheme, &hash)) {
 114                  fprintf(stderr, "Unknown scheme: %s\n", scheme);
 115                  exit(1);
 116          }
 117          if (Vflag == 1) {
 118                  const unsigned char *raw_password;
 119                  size_t size;
 120   
 121[+]                 if (password_decode(hash, scheme, &raw_password, &size) <= 0) {
expand/collapse

password_decode

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/auth/password-scheme.c)expand/collapse
Show more  
 129  int password_decode(const char *password, const char *scheme,
 130                      const unsigned char **raw_password_r, size_t *size_r)
 131  {
 132          const struct password_scheme *s;
 133          enum password_encoding encoding;
 134          buffer_t *buf;
 135          unsigned int len;
 136   
 137[+]         s = password_scheme_lookup(scheme, &encoding);
 138          if (s == NULL)
 139                  return 0;
 140   
 141          len = strlen(password);
 142          if (encoding != PW_ENCODING_NONE && s->raw_password_len != 0 &&
 143              strchr(scheme, '.') == NULL) {
 144                  /* encoding not specified. we can guess quite well between
 145                     base64 and hex encodings. the only problem is distinguishing 
 146                     2 character strings, but there shouldn't be any that short
 147                     raw_password_lens. */
 148                  encoding = len == s->raw_password_len * 2 ? PW_ENCODING_HEX :
 149                          PW_ENCODING_BASE64;
 150          }
 151   
 152          switch (encoding) {
 153          case PW_ENCODING_NONE:
 154                  *raw_password_r = (const unsigned char *)password;
 155                  *size_r = len;
 156                  break;
 157          case PW_ENCODING_HEX:
 158                  buf = buffer_create_static_hard(pool_datastack_create(),
 159                                                  len / 2 + 1);
 160                  if (hex_to_binary(password, buf) == 0) {
 161                          *raw_password_r = buf->data;
 162                          *size_r = buf->used;
 163                          break;
 164                  }
 165                  /* fall through, just in case it was base64-encoded after 
 166                     all. some input lengths produce matching hex and base64
 167                     encoded lengths. */
 168          case PW_ENCODING_BASE64:
 169                  buf = buffer_create_static_hard(pool_datastack_create(),
 170                                                  MAX_BASE64_DECODED_SIZE(len));
 171                  if (base64_decode(password, len, NULL, buf) < 0)
 172                          return -1;
 173   
 174                  *raw_password_r = buf->data;
 175                  *size_r = buf->used;
 176                  break;
 177          }
 178          if (s->raw_password_len != *size_r && s->raw_password_len != 0) {
Show more  
Show more  




Change Warning 8040.24663 : Uninitialized Variable

Priority:
State:
Finding:
Owner:
Note: