~vorlon/ubuntu/natty/eglibc/multiarch

« back to all changes in this revision

Viewing changes to nss/nss_files/files-hosts.c

  • Committer: Steve Langasek
  • Date: 2011-02-18 21:18:44 UTC
  • mfrom: (103.1.7 eglibc)
  • Revision ID: steve.langasek@linaro.org-20110218211844-lodmi8b1qhyq3f3x
Tags: 2.13~pre1-0ubuntu1+multiarch.1
merge from natty

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Hosts file parser in nss_files module.
2
 
   Copyright (C) 1996-2001, 2003-2008, 2009 Free Software Foundation, Inc.
 
2
   Copyright (C) 1996-2001, 2003-2009, 2011 Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
 
5
5
   The GNU C Library is free software; you can redistribute it and/or
129
129
          && _res_hconf.flags & HCONF_FLAG_MULTI)                             \
130
130
        {                                                                     \
131
131
          /* We have to get all host entries from the file.  */               \
132
 
          const size_t tmp_buflen = MIN (buflen, 4096);                       \
133
 
          char tmp_buffer[tmp_buflen]                                         \
 
132
          size_t tmp_buflen = MIN (buflen, 4096);                             \
 
133
          char tmp_buffer_stack[tmp_buflen]                                   \
134
134
            __attribute__ ((__aligned__ (__alignof__ (struct hostent_data))));\
 
135
          char *tmp_buffer = tmp_buffer_stack;                                \
135
136
          struct hostent tmp_result_buf;                                      \
136
137
          int naddrs = 1;                                                     \
137
138
          int naliases = 0;                                                   \
138
139
          char *bufferend;                                                    \
 
140
          bool tmp_buffer_malloced = false;                                   \
139
141
                                                                              \
140
142
          while (result->h_aliases[naliases] != NULL)                         \
141
143
            ++naliases;                                                       \
142
144
                                                                              \
143
145
          bufferend = (char *) &result->h_aliases[naliases + 1];              \
144
146
                                                                              \
 
147
        again:                                                                \
145
148
          while ((status = internal_getent (&tmp_result_buf, tmp_buffer,      \
146
149
                                            tmp_buflen, errnop H_ERRNO_ARG    \
147
150
                                            EXTRA_ARGS_VALUE))                \
182
185
                    }                                                         \
183
186
                  /* If the real name is different add it also to the         \
184
187
                     aliases.  This means that there is a duplication         \
185
 
                     in the alias list but this is really the users           \
 
188
                     in the alias list but this is really the user's          \
186
189
                     problem.  */                                             \
187
190
                  if (strcmp (old_result->h_name,                             \
188
191
                              tmp_result_buf.h_name) != 0)                    \
204
207
                      *errnop = ERANGE;                                       \
205
208
                      *herrnop = NETDB_INTERNAL;                              \
206
209
                      status = NSS_STATUS_TRYAGAIN;                           \
207
 
                      break;                                                  \
 
210
                      goto out;                                               \
208
211
                    }                                                         \
209
212
                                                                              \
210
213
                  new_h_addr_list =                                           \
268
271
                }                                                             \
269
272
            }                                                                 \
270
273
                                                                              \
271
 
          if (status != NSS_STATUS_TRYAGAIN)                                  \
 
274
          if (status == NSS_STATUS_TRYAGAIN)                                  \
 
275
            {                                                                 \
 
276
              size_t newsize = 2 * tmp_buflen;                                \
 
277
              if (tmp_buffer_malloced)                                        \
 
278
                {                                                             \
 
279
                  char *newp = realloc (tmp_buffer, newsize);                 \
 
280
                  if (newp != NULL)                                           \
 
281
                    {                                                         \
 
282
                      assert ((((uintptr_t) newp)                             \
 
283
                               & (__alignof__ (struct hostent_data) - 1))     \
 
284
                              == 0);                                          \
 
285
                      tmp_buffer = newp;                                      \
 
286
                      tmp_buflen = newsize;                                   \
 
287
                      goto again;                                             \
 
288
                    }                                                         \
 
289
                }                                                             \
 
290
              else if (!__libc_use_alloca (buflen + newsize))                 \
 
291
                {                                                             \
 
292
                  tmp_buffer = malloc (newsize);                              \
 
293
                  if (tmp_buffer != NULL)                                     \
 
294
                    {                                                         \
 
295
                      assert ((((uintptr_t) tmp_buffer)                       \
 
296
                               & (__alignof__ (struct hostent_data) - 1))     \
 
297
                              == 0);                                          \
 
298
                      tmp_buffer_malloced = true;                             \
 
299
                      tmp_buflen = newsize;                                   \
 
300
                      goto again;                                             \
 
301
                    }                                                         \
 
302
                }                                                             \
 
303
              else                                                            \
 
304
                {                                                             \
 
305
                  tmp_buffer                                                  \
 
306
                    = extend_alloca (tmp_buffer, tmp_buflen,                  \
 
307
                                     newsize                                  \
 
308
                                     + __alignof__ (struct hostent_data));    \
 
309
                  tmp_buffer = (char *) (((uintptr_t) tmp_buffer              \
 
310
                                          + __alignof__ (struct hostent_data) \
 
311
                                          - 1)                                \
 
312
                                         & ~(__alignof__ (struct hostent_data)\
 
313
                                             - 1));                           \
 
314
                  goto again;                                                 \
 
315
                }                                                             \
 
316
            }                                                                 \
 
317
          else                                                                \
272
318
            status = NSS_STATUS_SUCCESS;                                      \
 
319
        out:                                                                  \
 
320
          if (tmp_buffer_malloced)                                            \
 
321
            free (tmp_buffer);                                                \
273
322
        }                                                                     \
274
323
                                                                              \
275
324
                                                                              \