Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Call  at message-date.c:126

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

message_date_parser_tokens

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-mail/message-date.c)expand/collapse
Show more  
 110  message_date_parser_tokens(struct message_date_parser_context *ctx,
 111                             time_t *timestamp_r, int *timezone_offset_r)
 112  {
 113          struct tm tm;
 114          const unsigned char *value;
 115          size_t i, len;
 116          int ret;
 117   
 118          /* [weekday_name "," ] dd month_name [yy]yy hh:mi[:ss] timezone */
 119          memset(&tm, 0, sizeof(tm));
 120   
 121          (void)rfc822_skip_lwsp(&ctx->parser);
 122   
 123          /* skip the optional weekday */
 124          if (next_token(ctx, &value, &len) <= 0)
 125                  return FALSE;
 126          if (len == 3) {
 127                  if (*ctx->parser.data != ',')
 128                          return FALSE;
 129                  ctx->parser.data++;
 130                  (void)rfc822_skip_lwsp(&ctx->parser);
 131   
 132                  if (next_token(ctx, &value, &len) <= 0)
 133                          return FALSE;
 134          }
 135   
 136          /* dd */
 137          if (len < 1 || len > 2 || !i_isdigit(value[0]))
 138                  return FALSE;
 139   
 140          tm.tm_mday = value[0]-'0';
 141          if (len == 2) {
 142                  if (!i_isdigit(value[1]))
 143                          return FALSE;
 144                  tm.tm_mday = (tm.tm_mday * 10) + (value[1]-'0');
 145          }
 146   
 147          /* month name */
 148          if (next_token(ctx, &value, &len) <= 0 || len < 3)
 149                  return FALSE;
 150   
 151          for (i = 0; i < 12; i++) {
 152                  if (i_memcasecmp(month_names[i], value, 3) == 0) {
 153                          tm.tm_mon = i;
 154                          break;
 155                  }
 156          }
 157          if (i == 12)
 158                  return FALSE;
 159   
 160          /* [yy]yy */
 161          if (next_token(ctx, &value, &len) <= 0 || (len != 2 && len != 4))
 162                  return FALSE;
 163   
 164          for (i = 0; i < len; i++) {
 165                  if (!i_isdigit(value[i]))
 166                          return FALSE;
 167                  tm.tm_year = tm.tm_year * 10 + (value[i]-'0');
 168          }
 169   
 170          if (len == 2) {
 171                  /* two digit year, assume 1970+ */
 172                  if (tm.tm_year < 70)
 173                          tm.tm_year += 100;
 174          } else {
 175                  if (tm.tm_year < 1900)
 176                          return FALSE;
 177                  tm.tm_year -= 1900;
 178          }
 179   
 180          /* hh, allow also single digit */
 181          if (next_token(ctx, &value, &len) <= 0 ||
 182              len < 1 || len > 2 || !i_isdigit(value[0]))
 183                  return FALSE;
 184          tm.tm_hour = value[0]-'0';
 185          if (len == 2) {
 186                  if (!i_isdigit(value[1]))
 187                          return FALSE;
 188                  tm.tm_hour = tm.tm_hour * 10 + (value[1]-'0');
 189          }
 190   
 191          /* :mm (may be the last token) */
 192          if (*ctx->parser.data != ':')
 193                  return FALSE;
 194          ctx->parser.data++;
 195          (void)rfc822_skip_lwsp(&ctx->parser);
 196   
 197          if (next_token(ctx, &value, &len) < 0 || len != 2 ||
 198              !i_isdigit(value[0]) || !i_isdigit(value[1]))
 199                  return FALSE;
 200          tm.tm_min = (value[0]-'0') * 10 + (value[1]-'0');
 201   
 202          /* [:ss] */
 203          if (ctx->parser.data != ctx->parser.end && *ctx->parser.data == ':') {
 204                  ctx->parser.data++;
 205                  (void)rfc822_skip_lwsp(&ctx->parser);
 206   
 207                  if (next_token(ctx, &value, &len) <= 0 || len != 2 ||
 208                      !i_isdigit(value[0]) || !i_isdigit(value[1]))
 209                          return FALSE;
 210                  tm.tm_sec = (value[0]-'0') * 10 + (value[1]-'0');
 211          }
 212   
 213          if ((ret = next_token(ctx, &value, &len)) < 0)
 214                  return FALSE;
 215          if (ret == 0) {
 216                  /* missing timezone */
 217                  *timezone_offset_r = 0;
 218          } else {
 219                  /* timezone */
 220                  *timezone_offset_r = parse_timezone(value, len);
 221          }
 222   
 223          tm.tm_isdst = -1;
 224          *timestamp_r = utc_mktime(&tm);
 225          if (*timestamp_r == (time_t)-1)
 226                  return FALSE;
 227   
 228          *timestamp_r -= *timezone_offset_r * 60;
 229   
 230          return TRUE;
 231  }
Show more  




Change Warning 7158.24642 : Unreachable Call

Priority:
State:
Finding:
Owner:
Note: