Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at settings.c:191

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

settings_read_real

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-settings/settings.c)expand/collapse
Show more  
 91  settings_read_real(const char *path, const char *section,
 92                     settings_callback_t *callback,
 93                     settings_section_callback_t *sect_callback, void *context)
 94  {
 95          /* pretty horrible code, but v2.0 will have this rewritten anyway.. */
 96          struct input_stack root, *input, *new_input;
 97          const char *errormsg, *next_section, *name, *last_section_path = NULL;
 98          char *line, *key, *p, quote;
 99          string_t *full_line;
 100          size_t len;
 101          int fd, last_section_line = 0, skip, sections, root_section;
 102   
 103          fd = open(path, O_RDONLY);
 104          if (fd < 0) {
 105                  i_error("Can't open configuration file %s: %m", path);
 106                  return FALSE;
 107          }
 108   
 109          if (section == NULL) {
 110                  skip = 0;
 111                  next_section = NULL;
 112          } else {
 113                  skip = 1;
 114                  next_section = t_strcut(section, '/');
 115          }
 116   
 117          memset(&root, 0, sizeof(root));
 118          root.path = path;
 119          input = &root;
 120   
 121[+]         full_line = t_str_new(512);
 122          sections = 0; root_section = 0; errormsg = NULL;
 123  newfile:
 124          input->input = i_stream_create_fd(fd, 2048, TRUE);
 125          i_stream_set_return_partial_line(input->input, TRUE);
 126  prevfile:
 127[+]         while ((line = i_stream_read_next_line(input->input)) != NULL) {
 128                  input->linenum++;
 129   
 130                  /* @UNSAFE: line is modified */
 131   
 132                  /* skip whitespace */
 133                  while (IS_WHITE(*line))
 134                          line++;
 135   
 136                  /* ignore comments or empty lines */
 137                  if (*line == '#' || *line == '\0')
 138                          continue;
 139   
 140                  /* strip away comments. pretty kludgy way really.. */
 141                  for (p = line; *p != '\0'; p++) {
 142                          if (*p == '\'' || *p == '"') {
 143                                  quote = *p;
 144                                  for (p++; *p != quote && *p != '\0'; p++) {
 145                                          if (*p == '\\' && p[1] != '\0')
 146                                                  p++;
 147                                  }
 148                                  if (*p == '\0')
 149                                          break;
 150                          } else if (*p == '#') {
 151                                  *p = '\0';
 152                                  break;
 153                          }
 154                  }
 155   
 156                  /* remove whitespace from end of line */
 157                  len = strlen(line);
 158                  while (IS_WHITE(line[len-1]))
 159                          len--;
 160                  line[len] = '\0';
 161   
 162                  if (len > 0 && line[len-1] == '\\') {
 163                          /* continues in next line */
 164                          line[len-1] = '\0';
 165                          str_append(full_line, line);
 166                          continue;
 167                  }
 168                  if (str_len(full_line) > 0) {
 169                          str_append(full_line, line);
 170                          line = str_c_modifiable(full_line);
 171                  }
 172   
 173                  /* a) key = value 
 174                     b) section_type [section_name] {
 175                     c) } */
 176                  key = line;
 177                  while (!IS_WHITE(*line) && *line != '\0' && *line != '=')
 178                          line++;
 179                  if (IS_WHITE(*line)) {
 180                          *line++ = '\0';
 181                          while (IS_WHITE(*line)) line++;
 182                  }
 183   
 184                  if (strcmp(key, "!include_try") == 0 ||
 185                      strcmp(key, "!include") == 0) {
 186                          struct input_stack *tmp;
 187                          const char *path;
 188   
 189[+]                         path = fix_relative_path(line, input);
 190                          for (tmp = input; tmp != NULL; tmp = tmp->prev) {
 191                                  if (strcmp(tmp->path, path) == 0)
Show more  




Change Warning 7149.24786 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: