~ubuntu-branches/ubuntu/vivid/curl/vivid-security

« back to all changes in this revision

Viewing changes to lib/inet_pton.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-05-24 21:12:19 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (3.3.1 squeeze) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20090524211219-7jgcwuhl04ixuqsm
Tags: upstream-7.19.5
ImportĀ upstreamĀ versionĀ 7.19.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
  case AF_INET:
75
75
    return (inet_pton4(src, (unsigned char *)dst));
76
76
#ifdef ENABLE_IPV6
77
 
#ifndef AF_INET6
78
 
#define AF_INET6        (AF_MAX+1)        /* just to let this compile */
79
 
#endif
80
77
  case AF_INET6:
81
78
    return (inet_pton6(src, (unsigned char *)dst));
82
79
#endif
114
111
    if((pch = strchr(digits, ch)) != NULL) {
115
112
      unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
116
113
 
 
114
      if(saw_digit && *tp == 0)
 
115
        return (0);
117
116
      if(val > 255)
118
117
        return (0);
119
118
      *tp = (unsigned char)val;
134
133
  }
135
134
  if(octets < 4)
136
135
    return (0);
137
 
  /* bcopy(tmp, dst, INADDRSZ); */
138
136
  memcpy(dst, tmp, INADDRSZ);
139
137
  return (1);
140
138
}
181
179
    if(pch != NULL) {
182
180
      val <<= 4;
183
181
      val |= (pch - xdigits);
184
 
      if(val > 0xffff)
 
182
      if(++saw_xdigit > 4)
185
183
        return (0);
186
 
      saw_xdigit = 1;
187
184
      continue;
188
185
    }
189
186
    if(ch == ':') {
221
218
     * Since some memmove()'s erroneously fail to handle
222
219
     * overlapping regions, we'll do the shift by hand.
223
220
     */
224
 
    const int n = tp - colonp;
225
 
    int i;
 
221
    const long n = tp - colonp;
 
222
    long i;
226
223
 
 
224
    if(tp == endp)
 
225
      return (0);
227
226
    for (i = 1; i <= n; i++) {
228
227
      endp[- i] = colonp[n - i];
229
228
      colonp[n - i] = 0;
232
231
  }
233
232
  if(tp != endp)
234
233
    return (0);
235
 
  /* bcopy(tmp, dst, IN6ADDRSZ); */
236
234
  memcpy(dst, tmp, IN6ADDRSZ);
237
235
  return (1);
238
236
}