Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Overrun  at strfuncs.c:39

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

cmd_search_more

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/imap/imap-search.c)expand/collapse
Show more  
 318  static bool cmd_search_more(struct client_command_context *cmd)
 319  {
 320          struct imap_search_context *ctx = cmd->context;
 321          enum search_return_options opts = ctx->return_options;
 322          enum mailbox_sync_flags sync_flags;
 323          struct timeval end_time;
 324          const struct seq_range *range;
 325          unsigned int count;
 326          uint32_t id, id_min, id_max;
 327          const char *ok_reply;
 328          bool tryagain, minmax, lost_data;
 329   
 330          if (cmd->cancel) {
 331                  (void)imap_search_deinit(ctx);
 332                  return TRUE;
 333          }
 334   
 335          range = array_get(&ctx->result, &count);
 336          if (count == 0) {
 337                  id_min = 0;
 338                  id_max = 0;
 339          } else {
 340                  id_min = range[0].seq1;
 341                  id_max = range[count-1].seq2;
 342          }
 343   
 344          minmax = (opts & (SEARCH_RETURN_MIN | SEARCH_RETURN_MAX)) != 0 &&
 345                  (opts & ~(SEARCH_RETURN_NORESULTS |
 346                            SEARCH_RETURN_MIN | SEARCH_RETURN_MAX)) == 0;
 347          while (mailbox_search_next_nonblock(ctx->search_ctx, ctx->mail,
 348[+]                                             &tryagain) > 0) {
 349                  id = cmd->uid ? ctx->mail->uid : ctx->mail->seq;
 350                  ctx->result_count++;
 351   
 352                  if (minmax) {
 353                          /* we only care about min/max */
 354                          if (id_min == 0 && (opts & SEARCH_RETURN_MIN) != 0)
 355                                  id_min = id;
 356                          if ((opts & SEARCH_RETURN_MAX) != 0)
 357                                  id_max = id;
 358                          if (id == id_min || id == id_max) {
 359                                  /* return option updates are delayed until
 360                                     we know the actual min/max values */
 361                                  search_add_result_id(ctx, id);
 362                          }
 363                          continue;
 364                  }
 365   
 366                  search_update_mail(ctx);
 367                  if ((opts & ~(SEARCH_RETURN_NORESULTS |
 368                                SEARCH_RETURN_COUNT)) == 0) {
 369                          /* we only want to count (and get modseqs) */
 370                          continue;
 371                  }
 372                  search_add_result_id(ctx, id);
 373          }
 374          if (tryagain)
 375                  return FALSE;
 376   
 377          if (minmax && array_count(&ctx->result) > 0 &&
 378              (opts & (SEARCH_RETURN_MODSEQ | SEARCH_RETURN_SAVE)) != 0) {
 379                  /* handle MIN/MAX modseq/save updates */
 380                  if ((opts & SEARCH_RETURN_MIN) != 0) {
 381                          i_assert(id_min != 0);
 382                          if (cmd->uid) {
 383                                  if (!mail_set_uid(ctx->mail, id_min))
 384                                          i_unreached();
 385                          } else {
 386                                  mail_set_seq(ctx->mail, id_min);
 387                          }
 388                          search_update_mail(ctx);
 389                  }
 390                  if ((opts & SEARCH_RETURN_MAX) != 0) {
 391                          i_assert(id_max != 0);
 392                          if (cmd->uid) {
 393                                  if (!mail_set_uid(ctx->mail, id_max))
 394                                          i_unreached();
 395                          } else {
 396                                  mail_set_seq(ctx->mail, id_max);
 397                          }
 398                          search_update_mail(ctx);
 399                  }
 400          }
 401   
 402          lost_data = mailbox_search_seen_lost_data(ctx->search_ctx);
 403[+]         if (imap_search_deinit(ctx) < 0) {
 404                  client_send_storage_error(cmd,
 405                          mailbox_get_storage(cmd->client->mailbox));
 406                  return TRUE;
 407          }
 408   
 409          if (gettimeofday(&end_time, NULL) < 0)
 410                  memset(&end_time, 0, sizeof(end_time));
 411          end_time.tv_sec -= ctx->start_time.tv_sec;
 412          end_time.tv_usec -= ctx->start_time.tv_usec;
 413          if (end_time.tv_usec < 0) {
 414                  end_time.tv_sec--;
 415                  end_time.tv_usec += 1000000;
 416          }
 417   
 418          sync_flags = MAILBOX_SYNC_FLAG_FAST;
 419          if (!cmd->uid || ctx->have_seqsets)
 420                  sync_flags |= MAILBOX_SYNC_FLAG_NO_EXPUNGES;
 421          ok_reply = t_strdup_printf("OK %s%s completed (%d.%03d secs).",
 422                  lost_data ? "["IMAP_RESP_CODE_EXPUNGEISSUED"] " : "",
 423                  !ctx->sorting ? "Search"  : "Sort",
 424[+]                 (int)end_time.tv_sec, (int)(end_time.tv_usec/1000));
 425[+]         return cmd_sync(cmd, sync_flags, 0, ok_reply);
expand/collapse

cmd_sync

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/imap/imap-sync.c)expand/collapse
Show more  
 645  bool cmd_sync(struct client_command_context *cmd, enum mailbox_sync_flags flags,
 646                enum imap_sync_flags imap_flags, const char *tagline)
 647  {
 648[+]         return cmd_sync_full(cmd, flags, imap_flags, tagline, NULL);
expand/collapse

cmd_sync_full

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/imap/imap-sync.c)expand/collapse
Show more  
 610  cmd_sync_full(struct client_command_context *cmd, enum mailbox_sync_flags flags,
 611                enum imap_sync_flags imap_flags, const char *tagline,
 612                imap_sync_callback_t *callback)
 613  {
 614          struct client *client = cmd->client;
 615   
 616          i_assert(client->output_lock == cmd || client->output_lock == NULL);
 617   
 618          if (cmd->cancel)
 619                  return TRUE;
 620   
 621          if (client->mailbox == NULL) {
 622                  /* no mailbox selected, no point in delaying the sync */
 623                  i_assert(callback == NULL);
 624                  client_send_tagline(cmd, tagline);
 625                  return TRUE;
 626          }
 627   
 628          cmd->sync = p_new(cmd->pool, struct client_sync_context, 1);
 629          cmd->sync->counter = client->sync_counter;
 630          cmd->sync->flags = flags;
 631          cmd->sync->imap_flags = imap_flags;
 632[+]         cmd->sync->tagline = p_strdup(cmd->pool, tagline);
expand/collapse

p_strdup

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/strfuncs.c)expand/collapse
Show more  
 31  char *p_strdup(pool_t pool, const char *str)
 32  {
 33          void *mem;
 34          size_t len;
 35   
 36          if (str == NULL)
 37                  return NULL;
 38   
 39          for (len = 0; (str)[len] != '\0'; )
 40                  len++;
Show more  
Show more  
Show more  
Show more  




Change Warning 7986.24968 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: