Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at istream-raw-mbox.c:286

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

i_stream_raw_mbox_read

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/mbox/istream-raw-mbox.c)expand/collapse
Show more  
 169  static ssize_t i_stream_raw_mbox_read(struct istream_private *stream)
 170  {
 171          static const char *mbox_from = "\nFrom ";
 172          struct raw_mbox_istream *rstream = (struct raw_mbox_istream *)stream;
 173          const unsigned char *buf;
 174          const char *fromp;
 175          char *sender;
 176          time_t received_time;
 177          size_t i, pos, new_pos, from_start_pos, from_after_pos;
 178          ssize_t ret = 0;
 179          int eoh_char, tz;
 180          bool crlf_ending = FALSE;
 181   
 182          i_assert(rstream->seeked);
 183          i_assert(stream->istream.v_offset >= rstream->from_offset);
 184   
 185          if (stream->istream.eof)
 186                  return -1;
 187          if (rstream->corrupted) {
 188                  rstream->istream.istream.stream_errno = EINVAL;
 189                  return -1;
 190          }
 191   
 192          i_stream_seek(stream->parent, stream->istream.v_offset);
 193   
 194          stream->pos -= stream->skip;
 195          stream->skip = 0;
 196          stream->buffer = NULL;
 197   
 198          ret = 0;
 199          do {
 200[+]                 buf = i_stream_get_data(stream->parent, &pos);
 201                  if (pos > 1 && stream->istream.v_offset + pos >
 202                      rstream->input_peak_offset) {
 203                          /* fake our read count. needed because if in the end
 204                             we have only one character in buffer and we skip it
 205                             (as potential CR), we want to get back to this 
 206                             i_stream_raw_mbox_read() to read more data. */
 207                          ret = pos;
 208                          break;
 209                  }
 210[+]                 ret = i_stream_read(stream->parent);
 211          } while (ret > 0);
 212          stream->istream.stream_errno = stream->parent->stream_errno;
 213   
 214          if (ret < 0) {
 215                  if (ret == -2) {
 216                          if (stream->skip == stream->pos) {
 217                                  /* From_-line is longer than our input buffer.
 218                                     finish the check without seeing the LF. */
 219                          } else if (stream->istream.v_offset + pos ==
 220                                     rstream->input_peak_offset) {
 221                                  /* we've read everything our parent stream 
 222                                     has to offer. */
 223                                  stream->buffer = buf;
 224                                  return -2;
 225
247
Show [ Lines 225 to 247 omitted. ]
 248                                     stream is now at EOF */
 249                                  rstream->eof = TRUE;
 250                          }
 251                          stream->istream.eof = TRUE;
 252                          rstream->crlf_ending = crlf_ending;
 253                          handle_end_of_mail(rstream, pos);
 254                          return ret < 0 ? i_stream_raw_mbox_read(stream) : ret;
 255                  }
 256          }
 257   
 258          if (stream->istream.v_offset == rstream->from_offset) {
 259                  /* beginning of message, we haven't yet read our From-line */
 260                  if (pos == 2 && ret > 0) {
 261                          /* we're at the end of file with CR+LF linefeeds?
 262                             need more data to verify it. */
 263                          rstream->input_peak_offset =
 264                                  stream->istream.v_offset + pos;
 265                          return i_stream_raw_mbox_read(stream);
 266                  }
 267                  if (mbox_read_from_line(rstream) < 0) {
 268                          stream->pos = 0;
 269                          rstream->eof = TRUE;
 270                          rstream->corrupted = TRUE;
 271                          return -1;
 272                  }
 273   
 274                  /* got it. we don't want to return it however,
 275                     so start again from headers */
 276                  buf = i_stream_get_data(stream->parent, &pos);
 277                  if (pos == 0)
 278                          return i_stream_raw_mbox_read(stream);
 279          }
 280   
 281          /* See if we have From-line here - note that it works right only
 282             because all characters are different in mbox_from. */
 283          fromp = mbox_from; from_start_pos = from_after_pos = (size_t)-1;
 284          eoh_char = rstream->body_offset == (uoff_t)-1 ? '\n' : -1;
 285          for (i = stream->pos; i < pos; i++) {
 286                  if (buf[i] == eoh_char &&
Show more  




Change Warning 7396.24570 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: