~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/inet_ntop.c

  • Committer: Package Import Robot
  • Author(s): Luigi Gangitano
  • Date: 2011-09-02 13:33:41 UTC
  • mto: (21.2.8 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20110902133341-56p01dh4mh6e308v
Tags: upstream-3.1.15
ImportĀ upstreamĀ versionĀ 3.1.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 *    28-Oct-2007: drop some dead code. now tested working without.
16
16
 *
 
17
 *    04-Nov-2010: drop SPRINTF casting macro
 
18
 *
17
19
 * Squid CVS $Id$
18
20
 *
19
21
 *  Original License and code follows.
72
74
#include <string.h>
73
75
#endif
74
76
 
75
 
#ifdef SPRINTF_CHAR
76
 
# define SPRINTF(x) strlen(sprintf/**/x)
77
 
#else
78
 
# define SPRINTF(x) ((size_t)sprintf x)
79
 
#endif
80
 
 
81
77
#if ! defined(NS_INADDRSZ)
82
78
#define NS_INADDRSZ      4
83
79
#endif
143
139
    static const char fmt[] = "%u.%u.%u.%u";
144
140
    char tmp[sizeof "255.255.255.255"];
145
141
 
146
 
    if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) {
 
142
    if (snprintf(tmp, min(sizeof("255.255.255.255"),size), fmt, src[0], src[1], src[2], src[3]) >= size) {
147
143
        errno = ENOSPC;
148
144
        return (NULL);
149
145
    }
232
228
            tp += strlen(tp);
233
229
            break;
234
230
        }
235
 
        tp += SPRINTF((tp, "%x", words[i]));
 
231
        tp += snprintf(tp, (tmp + sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") - tp), "%x", words[i]);
236
232
    }
237
233
    /* Was it a trailing run of 0x00's? */
238
234
    if (best.base != -1 && (best.base + best.len) ==