~vorlon/ubuntu/natty/curl/multiarch

« back to all changes in this revision

Viewing changes to lib/inet_ntop.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-04-29 11:10:29 UTC
  • mfrom: (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090429111029-2j5eiyokfw2bw049
Tags: 7.19.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop build dependencies: stunnel, libdb4.6-dev, libssh2-1-dev
  - Add build-dependency on openssh-server
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Call automake-1.9 with --add-missing --copy --force
* drop debian/patches/security_CVE-2009-0037.patch 
  - this patch is part of 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
#include "inet_ntop.h"
44
44
 
45
 
#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
46
 
/* this platform has a inet_ntoa_r() function, but no proto declared anywhere
47
 
   so we include our own proto to make compilers happy */
48
 
#include "inet_ntoa_r.h"
49
 
#endif
50
 
 
51
45
#define IN6ADDRSZ       16
52
46
#define INADDRSZ         4
53
47
#define INT16SZ          2
62
56
 */
63
57
static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
64
58
{
65
 
#if defined(HAVE_INET_NTOA_R_2_ARGS)
66
 
  const char *ptr;
 
59
  char tmp[sizeof "255.255.255.255"];
 
60
  size_t len;
 
61
 
67
62
  DEBUGASSERT(size >= 16);
68
 
  ptr = inet_ntoa_r(*(struct in_addr*)src, dst);
69
 
  return (char *)memmove(dst, ptr, strlen(ptr)+1);
70
 
 
71
 
#elif defined(HAVE_INET_NTOA_R)
72
 
 
73
 
#if defined(HAVE_INT_INET_NTOA_R)
74
 
  return inet_ntoa_r(*(struct in_addr*)src, dst, size)? NULL: dst;
75
 
#else
76
 
  return inet_ntoa_r(*(struct in_addr*)src, dst, size);
77
 
#endif
78
 
 
79
 
#else
80
 
  const char *addr = inet_ntoa(*(struct in_addr*)src);
81
 
 
82
 
  if(strlen(addr) >= size)
 
63
 
 
64
  tmp[0] = '\0';
 
65
  (void)snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
 
66
          ((int)((unsigned char)src[0])) & 0xff,
 
67
          ((int)((unsigned char)src[1])) & 0xff,
 
68
          ((int)((unsigned char)src[2])) & 0xff,
 
69
          ((int)((unsigned char)src[3])) & 0xff);
 
70
 
 
71
  len = strlen(tmp);
 
72
  if(len == 0 || len >= size)
83
73
  {
84
74
    SET_ERRNO(ENOSPC);
85
75
    return (NULL);
86
76
  }
87
 
  return strcpy(dst, addr);
88
 
#endif
 
77
  strcpy(dst, tmp);
 
78
  return dst;
89
79
}
90
80
 
91
81
#ifdef ENABLE_IPV6
192
182
    SET_ERRNO(ENOSPC);
193
183
    return (NULL);
194
184
  }
195
 
  return strcpy (dst, tmp);
 
185
  strcpy(dst, tmp);
 
186
  return dst;
196
187
}
197
188
#endif  /* ENABLE_IPV6 */
198
189