diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-17 16:05:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-17 16:05:12 +0000 |
commit | 80fe62b325c38576e6cccafd39824aa9d5624607 (patch) | |
tree | e634eaba053b9f9815e51e6d05ccd4c0ecec2d24 /src/util | |
parent | b1d1f2b1d9e58d1b4b91299c7a48b30bd730d4c4 (diff) | |
download | gnunet-80fe62b325c38576e6cccafd39824aa9d5624607.tar.gz gnunet-80fe62b325c38576e6cccafd39824aa9d5624607.zip |
use GNUNET_snprintf
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/common_logging.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 5faa4af73..ddb71a2c1 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -1137,11 +1137,12 @@ GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid) | |||
1137 | * will be overwritten by next call to #GNUNET_a2s. | 1137 | * will be overwritten by next call to #GNUNET_a2s. |
1138 | */ | 1138 | */ |
1139 | const char * | 1139 | const char * |
1140 | GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) | 1140 | GNUNET_a2s (const struct sockaddr *addr, |
1141 | socklen_t addrlen) | ||
1141 | { | 1142 | { |
1142 | #ifndef WINDOWS | 1143 | #ifndef WINDOWS |
1143 | #define LEN GNUNET_MAX ((INET6_ADDRSTRLEN + 8), \ | 1144 | #define LEN GNUNET_MAX ((INET6_ADDRSTRLEN + 8), \ |
1144 | (sizeof (struct sockaddr_un) - sizeof (sa_family_t))) | 1145 | (1 + sizeof (struct sockaddr_un) - sizeof (sa_family_t))) |
1145 | #else | 1146 | #else |
1146 | #define LEN (INET6_ADDRSTRLEN + 8) | 1147 | #define LEN (INET6_ADDRSTRLEN + 8) |
1147 | #endif | 1148 | #endif |
@@ -1188,9 +1189,12 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) | |||
1188 | if ('\0' == un->sun_path[0]) | 1189 | if ('\0' == un->sun_path[0]) |
1189 | off++; | 1190 | off++; |
1190 | memset (buf, 0, sizeof (buf)); | 1191 | memset (buf, 0, sizeof (buf)); |
1191 | snprintf (buf, sizeof (buf) - 1, "%s%.*s", (off == 1) ? "@" : "", | 1192 | GNUNET_snprintf (buf, |
1192 | (int) (addrlen - sizeof (sa_family_t) - 1 - off), | 1193 | sizeof (buf), |
1193 | &un->sun_path[off]); | 1194 | "%s%.*s", |
1195 | (1 == off) ? "@" : "", | ||
1196 | (int) (addrlen - sizeof (sa_family_t) - off), | ||
1197 | &un->sun_path[off]); | ||
1194 | return buf; | 1198 | return buf; |
1195 | default: | 1199 | default: |
1196 | return _("invalid address"); | 1200 | return _("invalid address"); |