Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Overrun  at var-expand.c:242

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

expand_envs

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/deliver/deliver.c)expand/collapse
Show more  
 815  static void expand_envs(const char *user)
 816  {
 817          const struct var_expand_table *table;
 818          const char *value, *const *envs, *home, *env_name;
 819          unsigned int i, count;
 820          string_t *str;
 821   
 822          home = getenv("HOME");
 823   
 824          str = t_str_new(256);
 825          table = get_var_expand_table(user, home);
 826[+]         envs = array_get(&plugin_envs, &count);
 827          for (i = 0; i < count; i++) {
 828                  str_truncate(str, 0);
 829                  var_expand(str, envs[i], table);
 830                  env_put(str_c(str));
 831          }
 832          /* add LDA envs again to make sure they override plugin settings */
 833[+]         envs = array_get(&lda_envs, &count);
 834          for (i = 0; i < count; i++)
 835                  env_put(envs[i]);
 836   
 837          /* get the table again in case plugin envs provided the home 
 838             directory (yea, kludgy) */
 839          if (home == NULL)
 840                  home = getenv("HOME");
 841          table = get_var_expand_table(user, home);
 842   
 843          value = getenv("MAIL_LOCATION");
 844          if (value != NULL)
 845                  value = expand_mail_env(value, table);
 846          env_put(t_strconcat("MAIL=", value, NULL));
 847   
 848          for (i = 1;; i++) {
 849                  env_name = t_strdup_printf("NAMESPACE_%u", i);
 850                  value = getenv(env_name);
 851                  if (value == NULL)
 852                          break;
 853   
 854[+]                 value = expand_mail_env(value, table);
expand/collapse

expand_mail_env

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/deliver/deliver.c)expand/collapse
Show more  
 549  static const char *
 550  expand_mail_env(const char *env, const struct var_expand_table *table)
 551  {
 552          string_t *str;
 553          const char *p;
 554   
 555          str = t_str_new(256);
 556   
 557          /* it's either type:data or just data */
 558          p = strchr(env, ':');
 559          if (p != NULL) {
 560                  while (env != p) {
 561                          str_append_c(str, *env);
 562                          env++;
 563                  }
 564   
 565                  str_append_c(str, *env++);
 566          }
 567   
 568          if (env[0] == '~' && env[1] == '/') {
 569                  /* expand home */
 570                  env = t_strconcat("%h", env+1, NULL);
 571          }
 572   
 573          /* expand %vars */
 574[+]         var_expand(str, env, table);
expand/collapse

var_expand

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/var-expand.c)expand/collapse
Show more  
 139  void var_expand(string_t *dest, const char *str,
 140                  const struct var_expand_table *table)
 141  {
 142          const struct var_expand_modifier *m;
 143          const struct var_expand_table *t;
 144          const char *var;
 145          struct var_expand_context ctx;
 146          const char *(*modifier[MAX_MODIFIER_COUNT])
 147                  (const char *, struct var_expand_context *);
 148          const char *end;
 149          unsigned int i, len, modifier_count;
 150   
 151          memset(&ctx, 0, sizeof(ctx));
 152          for (; *str != '\0'; str++) {
 153                  if (*str != '%')
 154                          str_append_c(dest, *str);
 155                  else {
 156                          int sign = 1;
 157   
 158                          str++;
 159                          memset(&ctx, 0, sizeof(ctx));
 160   
 161                          /* [<offset>.]<width>[<modifiers>]<variable> */
 162                          if (*str == '-') {
 163                                  sign = -1;
 164                                  str++;
 165                          }
 166                          if (*str == '0') {
 167                                  ctx.zero_padding = TRUE;
 168                                  str++;
 169                          }
 170                          while (*str >= '0' && *str <= '9') {
 171                                  ctx.width = ctx.width*10 + (*str - '0');
 172                                  str++;
 173                          }
 174   
 175                          if (*str == '.') {
 176                                  ctx.offset = sign * (int)ctx.width;
 177                                  ctx.width = 0;
 178                                  str++;
 179   
 180                                  /* if offset was prefixed with zero (or it was
 181                                     plain zero), just ignore that. zero padding
 182                                     is done with the width. */
 183                                  ctx.zero_padding = FALSE;
 184                                  if (*str == '0') {
 185                                          ctx.zero_padding = TRUE;
 186                                          str++;
 187                                  }
 188   
 189                                  while (*str >= '0' && *str <= '9') {
 190                                          ctx.width = ctx.width*10 + (*str - '0');
 191                                          str++;
 192                                  }
 193                          }
 194   
 195                          modifier_count = 0;
 196                          while (modifier_count < MAX_MODIFIER_COUNT) {
 197                                  modifier[modifier_count] = NULL;
 198                                  for (m = modifiers; m->key != '\0'; m++) {
 199                                          if (m->key == *str) {
 200                                                  /* @UNSAFE */
 201                                                  modifier[modifier_count] =
 202                                                          m->func;
 203                                                  str++;
 204                                                  break;
 205                                          }
 206                                  }
 207                                  if (modifier[modifier_count] == NULL)
 208                                          break;
 209                                  modifier_count++;
 210                          }
 211   
 212                          if (*str == '\0')
 213                                  break;
 214   
 215                          var = NULL;
 216                          if (*str == '{' && (end = strchr(str, '}')) != NULL) {
 217                                  /* %{long_key} */
 218                                  len = end - (str + 1);
 219                                  for (t = table; !TABLE_LAST(t); t++) {
 220                                          if (t->long_key != NULL &&
 221                                              strncmp(t->long_key, str+1,
 222                                                      len) == 0 &&
 223                                              t->long_key[len] == '\0') {
 224                                                  var = t->value != NULL ?
 225                                                          t->value : "";
 226                                                  str = end;
 227                                                  break;
 228                                          }
 229                                  }
 230                          } else {
 231                                  for (t = table; !TABLE_LAST(t); t++) {
 232                                          if (t->key == *str) {
 233                                                  var = t->value != NULL ?
 234                                                          t->value : "";
 235                                                  break;
 236                                          }
 237                                  }
 238                          }
 239   
 240                          if (var == NULL) {
 241                                  /* not found */
 242                                  if (*str == '%')
Show more  
Show more  
Show more  




Change Warning 8015.24815 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: