~ubuntu-branches/ubuntu/natty/postfix/natty-security

« back to all changes in this revision

Viewing changes to src/cleanup/cleanup_map1n.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2011-02-22 05:26:41 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20110222052641-l05d2bsz2kka0yca
Tags: 2.8.0-1~build1
natty version

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
/*      This module implements one-to-many table mapping via table lookup.
16
16
/*      Table lookups are done with quoted (externalized) address forms.
17
17
/*      The process is recursive. The recursion terminates when the
18
 
/*      left-hand side appears in its own expansion, or when a maximal
19
 
/*      nesting level is reached.
 
18
/*      left-hand side appears in its own expansion.
20
19
/*
21
20
/*      cleanup_map1n_internal() is the interface for addresses in
22
21
/*      internal (unquoted) form.
23
22
/* DIAGNOSTICS
24
 
/*      Recoverable errors: the global \fIcleanup_errs\fR flag is updated.
 
23
/*      When the maximal expansion or recursion limit is reached,
 
24
/*      the alias is not expanded and the CLEANUP_STAT_DEFER error
 
25
/*      is raised with reason "4.6.0 Alias expansion error".
 
26
/*
 
27
/*      When table lookup fails, the alias is not expanded and the
 
28
/*      CLEANUP_STAT_WRITE error is raised with reason "4.6.0 Alias
 
29
/*      expansion error".
25
30
/* SEE ALSO
26
31
/*      mail_addr_map(3) address mappings
27
32
/*      mail_addr_find(3) address lookups
93
98
     * must index the array explicitly, instead of running along it with a
94
99
     * pointer.
95
100
     */
96
 
#define UPDATE(ptr,new) { myfree(ptr); ptr = mystrdup(new); }
 
101
#define UPDATE(ptr,new) do { \
 
102
        if (ptr) myfree(ptr); ptr = mystrdup(new); \
 
103
    } while (0)
97
104
#define STR     vstring_str
98
 
#define RETURN(x) { been_here_free(been_here); return (x); }
 
105
#define RETURN(x) do { \
 
106
        been_here_free(been_here); return (x); \
 
107
    } while (0)
 
108
#define UNEXPAND(argv, addr) do { \
 
109
        argv_truncate((argv), 0); argv_add((argv), (addr), (char *) 0); \
 
110
    } while (0)
99
111
 
100
112
    for (arg = 0; arg < argv->argc; arg++) {
101
113
        if (argv->argc > var_virt_expan_limit) {
102
 
            msg_warn("%s: unreasonable %s map expansion size for %s",
 
114
            msg_warn("%s: unreasonable %s map expansion size for %s -- "
 
115
                     "deferring delivery",
103
116
                     state->queue_id, maps->title, addr);
104
 
            break;
 
117
            state->errs |= CLEANUP_STAT_DEFER;
 
118
            UPDATE(state->reason, "4.6.0 Alias expansion error");
 
119
            UNEXPAND(argv, addr);
 
120
            RETURN(argv);
105
121
        }
106
122
        for (count = 0; /* void */ ; count++) {
107
123
 
111
127
            if (been_here_check_fixed(been_here, argv->argv[arg]) != 0)
112
128
                break;
113
129
            if (count >= var_virt_recur_limit) {
114
 
                msg_warn("%s: unreasonable %s map nesting for %s",
 
130
                msg_warn("%s: unreasonable %s map nesting for %s -- "
 
131
                         "deferring delivery",
115
132
                         state->queue_id, maps->title, addr);
116
 
                break;
 
133
                state->errs |= CLEANUP_STAT_DEFER;
 
134
                UPDATE(state->reason, "4.6.0 Alias expansion error");
 
135
                UNEXPAND(argv, addr);
 
136
                RETURN(argv);
117
137
            }
118
138
            quote_822_local(state->temp1, argv->argv[arg]);
119
139
            if ((lookup = mail_addr_map(maps, STR(state->temp1), propagate)) != 0) {
136
156
                myfree(saved_lhs);
137
157
                argv_free(lookup);
138
158
            } else if (dict_errno != 0) {
139
 
                msg_warn("%s: %s map lookup problem for %s",
 
159
                msg_warn("%s: %s map lookup problem for %s -- "
 
160
                         "deferring delivery",
140
161
                         state->queue_id, maps->title, addr);
141
162
                state->errs |= CLEANUP_STAT_WRITE;
 
163
                UPDATE(state->reason, "4.6.0 Alias expansion error");
 
164
                UNEXPAND(argv, addr);
142
165
                RETURN(argv);
143
166
            } else {
144
167
                break;