(expand_aliases): Bugfix. Do not use statically allocated buffer. Use header_age…
…t_field_name() instead. The utility freezed with header names longer than 16 bytes.
Showing
1 changed file
with
23 additions
and
20 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 2003, 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -364,7 +364,7 @@ expand_aliases (message_t msg) | ... | @@ -364,7 +364,7 @@ expand_aliases (message_t msg) |
364 | { | 364 | { |
365 | header_t hdr; | 365 | header_t hdr; |
366 | size_t i, num; | 366 | size_t i, num; |
367 | char buf[16]; | 367 | char *buf; |
368 | address_t addr_to = NULL, | 368 | address_t addr_to = NULL, |
369 | addr_cc = NULL, | 369 | addr_cc = NULL, |
370 | addr_bcc = NULL; | 370 | addr_bcc = NULL; |
... | @@ -373,25 +373,28 @@ expand_aliases (message_t msg) | ... | @@ -373,25 +373,28 @@ expand_aliases (message_t msg) |
373 | header_get_field_count (hdr, &num); | 373 | header_get_field_count (hdr, &num); |
374 | for (i = 1; i <= num; i++) | 374 | for (i = 1; i <= num; i++) |
375 | { | 375 | { |
376 | header_get_field_name (hdr, i, buf, sizeof buf, NULL); | 376 | if (header_aget_field_name (hdr, i, &buf) == 0) |
377 | if (strcasecmp (buf, MU_HEADER_TO) == 0 | ||
378 | || strcasecmp (buf, MU_HEADER_CC) == 0 | ||
379 | || strcasecmp (buf, MU_HEADER_BCC) == 0) | ||
380 | { | 377 | { |
381 | char *value; | 378 | if (strcasecmp (buf, MU_HEADER_TO) == 0 |
382 | address_t addr = NULL; | 379 | || strcasecmp (buf, MU_HEADER_CC) == 0 |
383 | int incl; | 380 | || strcasecmp (buf, MU_HEADER_BCC) == 0) |
384 | 381 | { | |
385 | header_aget_field_value_unfold (hdr, i, &value); | 382 | char *value; |
386 | 383 | address_t addr = NULL; | |
387 | mh_alias_expand (value, &addr, &incl); | 384 | int incl; |
388 | free (value); | 385 | |
389 | if (strcasecmp (buf, MU_HEADER_TO) == 0) | 386 | header_aget_field_value_unfold (hdr, i, &value); |
390 | address_union (&addr_to, addr); | 387 | |
391 | else if (strcasecmp (buf, MU_HEADER_CC) == 0) | 388 | mh_alias_expand (value, &addr, &incl); |
392 | address_union (&addr_cc, addr); | 389 | free (value); |
393 | else if (strcasecmp (buf, MU_HEADER_BCC) == 0) | 390 | if (strcasecmp (buf, MU_HEADER_TO) == 0) |
394 | address_union (&addr_bcc, addr); | 391 | address_union (&addr_to, addr); |
392 | else if (strcasecmp (buf, MU_HEADER_CC) == 0) | ||
393 | address_union (&addr_cc, addr); | ||
394 | else if (strcasecmp (buf, MU_HEADER_BCC) == 0) | ||
395 | address_union (&addr_bcc, addr); | ||
396 | } | ||
397 | free (buf); | ||
395 | } | 398 | } |
396 | } | 399 | } |
397 | 400 | ... | ... |
-
Please register or sign in to post a comment