diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/inet_common.c | 51 | ||||
-rw-r--r-- | libbb/lineedit.c | 4 | ||||
-rw-r--r-- | libbb/messages.c | 3 | ||||
-rw-r--r-- | libbb/xconnect.c | 5 |
4 files changed, 32 insertions, 31 deletions
diff --git a/libbb/inet_common.c b/libbb/inet_common.c index 9cdcb11de..6b31c79f2 100644 --- a/libbb/inet_common.c +++ b/libbb/inet_common.c | |||
@@ -33,19 +33,23 @@ int INET_resolve(const char *name, struct sockaddr_in *s_in, int hostfirst) | |||
33 | /* If we expect this to be a hostname, try hostname database first */ | 33 | /* If we expect this to be a hostname, try hostname database first */ |
34 | #ifdef DEBUG | 34 | #ifdef DEBUG |
35 | if (hostfirst) { | 35 | if (hostfirst) { |
36 | bb_error_msg("gethostbyname (%s)", name); | 36 | bb_error_msg("gethostbyname(%s)", name); |
37 | } | 37 | } |
38 | #endif | 38 | #endif |
39 | if (hostfirst && (hp = gethostbyname(name)) != (struct hostent *) NULL) { | 39 | if (hostfirst) { |
40 | memcpy((char *) &s_in->sin_addr, (char *) hp->h_addr_list[0], | 40 | hp = gethostbyname(name); |
41 | sizeof(struct in_addr)); | 41 | if (hp != NULL) { |
42 | return 0; | 42 | memcpy(&s_in->sin_addr, hp->h_addr_list[0], |
43 | sizeof(struct in_addr)); | ||
44 | return 0; | ||
45 | } | ||
43 | } | 46 | } |
44 | /* Try the NETWORKS database to see if this is a known network. */ | 47 | /* Try the NETWORKS database to see if this is a known network. */ |
45 | #ifdef DEBUG | 48 | #ifdef DEBUG |
46 | bb_error_msg("getnetbyname (%s)", name); | 49 | bb_error_msg("getnetbyname(%s)", name); |
47 | #endif | 50 | #endif |
48 | if ((np = getnetbyname(name)) != (struct netent *) NULL) { | 51 | np = getnetbyname(name); |
52 | if (np != NULL) { | ||
49 | s_in->sin_addr.s_addr = htonl(np->n_net); | 53 | s_in->sin_addr.s_addr = htonl(np->n_net); |
50 | return 1; | 54 | return 1; |
51 | } | 55 | } |
@@ -59,14 +63,13 @@ int INET_resolve(const char *name, struct sockaddr_in *s_in, int hostfirst) | |||
59 | #endif | 63 | #endif |
60 | 64 | ||
61 | #ifdef DEBUG | 65 | #ifdef DEBUG |
62 | bb_error_msg("gethostbyname (%s)", name); | 66 | bb_error_msg("gethostbyname(%s)", name); |
63 | #endif | 67 | #endif |
64 | if ((hp = gethostbyname(name)) == (struct hostent *) NULL) { | 68 | hp = gethostbyname(name); |
69 | if (hp == NULL) { | ||
65 | return -1; | 70 | return -1; |
66 | } | 71 | } |
67 | memcpy((char *) &s_in->sin_addr, (char *) hp->h_addr_list[0], | 72 | memcpy(&s_in->sin_addr, hp->h_addr_list[0], sizeof(struct in_addr)); |
68 | sizeof(struct in_addr)); | ||
69 | |||
70 | return 0; | 73 | return 0; |
71 | } | 74 | } |
72 | 75 | ||
@@ -78,7 +81,7 @@ struct addr { | |||
78 | struct addr *next; | 81 | struct addr *next; |
79 | }; | 82 | }; |
80 | 83 | ||
81 | static struct addr *INET_nn = NULL; /* addr-to-name cache */ | 84 | static struct addr *INET_nn = NULL; /* addr-to-name cache */ |
82 | 85 | ||
83 | /* numeric: & 0x8000: default instead of *, | 86 | /* numeric: & 0x8000: default instead of *, |
84 | * & 0x4000: host instead of net, | 87 | * & 0x4000: host instead of net, |
@@ -90,7 +93,7 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
90 | struct hostent *ent; | 93 | struct hostent *ent; |
91 | struct netent *np; | 94 | struct netent *np; |
92 | struct addr *pn; | 95 | struct addr *pn; |
93 | unsigned long ad, host_ad; | 96 | uint32_t ad, host_ad; |
94 | int host = 0; | 97 | int host = 0; |
95 | 98 | ||
96 | /* Grmpf. -FvK */ | 99 | /* Grmpf. -FvK */ |
@@ -102,9 +105,9 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
102 | errno = EAFNOSUPPORT; | 105 | errno = EAFNOSUPPORT; |
103 | return -1; | 106 | return -1; |
104 | } | 107 | } |
105 | ad = (unsigned long) s_in->sin_addr.s_addr; | 108 | ad = s_in->sin_addr.s_addr; |
106 | #ifdef DEBUG | 109 | #ifdef DEBUG |
107 | bb_error_msg("rresolve: %08lx, mask %08x, num %08x", ad, netmask, numeric); | 110 | bb_error_msg("rresolve: %08x, mask %08x, num %08x", (unsigned)ad, netmask, numeric); |
108 | #endif | 111 | #endif |
109 | if (ad == INADDR_ANY) { | 112 | if (ad == INADDR_ANY) { |
110 | if ((numeric & 0x0FFF) == 0) { | 113 | if ((numeric & 0x0FFF) == 0) { |
@@ -127,8 +130,8 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
127 | if (pn->addr.sin_addr.s_addr == ad && pn->host == host) { | 130 | if (pn->addr.sin_addr.s_addr == ad && pn->host == host) { |
128 | safe_strncpy(name, pn->name, len); | 131 | safe_strncpy(name, pn->name, len); |
129 | #ifdef DEBUG | 132 | #ifdef DEBUG |
130 | bb_error_msg("rresolve: found %s %08lx in cache", | 133 | bb_error_msg("rresolve: found %s %08x in cache", |
131 | (host ? "host" : "net"), ad); | 134 | (host ? "host" : "net"), (unsigned)ad); |
132 | #endif | 135 | #endif |
133 | return 0; | 136 | return 0; |
134 | } | 137 | } |
@@ -140,7 +143,7 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
140 | ent = NULL; | 143 | ent = NULL; |
141 | if (host) { | 144 | if (host) { |
142 | #ifdef DEBUG | 145 | #ifdef DEBUG |
143 | bb_error_msg("gethostbyaddr (%08lx)", ad); | 146 | bb_error_msg("gethostbyaddr (%08x)", (unsigned)ad); |
144 | #endif | 147 | #endif |
145 | ent = gethostbyaddr((char *) &ad, 4, AF_INET); | 148 | ent = gethostbyaddr((char *) &ad, 4, AF_INET); |
146 | if (ent != NULL) { | 149 | if (ent != NULL) { |
@@ -148,14 +151,14 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
148 | } | 151 | } |
149 | } else { | 152 | } else { |
150 | #ifdef DEBUG | 153 | #ifdef DEBUG |
151 | bb_error_msg("getnetbyaddr (%08lx)", host_ad); | 154 | bb_error_msg("getnetbyaddr (%08x)", (unsigned)host_ad); |
152 | #endif | 155 | #endif |
153 | np = getnetbyaddr(host_ad, AF_INET); | 156 | np = getnetbyaddr(host_ad, AF_INET); |
154 | if (np != NULL) { | 157 | if (np != NULL) { |
155 | safe_strncpy(name, np->n_name, len); | 158 | safe_strncpy(name, np->n_name, len); |
156 | } | 159 | } |
157 | } | 160 | } |
158 | if ((ent == NULL) && (np == NULL)) { | 161 | if (!ent && !np) { |
159 | safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); | 162 | safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); |
160 | } | 163 | } |
161 | pn = xmalloc(sizeof(struct addr)); | 164 | pn = xmalloc(sizeof(struct addr)); |
@@ -164,7 +167,6 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
164 | pn->host = host; | 167 | pn->host = host; |
165 | pn->name = xstrdup(name); | 168 | pn->name = xstrdup(name); |
166 | INET_nn = pn; | 169 | INET_nn = pn; |
167 | |||
168 | return 0; | 170 | return 0; |
169 | } | 171 | } |
170 | 172 | ||
@@ -183,9 +185,7 @@ int INET6_resolve(const char *name, struct sockaddr_in6 *sin6) | |||
183 | return -1; | 185 | return -1; |
184 | } | 186 | } |
185 | memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6)); | 187 | memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6)); |
186 | |||
187 | freeaddrinfo(ai); | 188 | freeaddrinfo(ai); |
188 | |||
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
@@ -224,7 +224,8 @@ int INET6_rresolve(char *name, size_t len, struct sockaddr_in6 *sin6, | |||
224 | return 0; | 224 | return 0; |
225 | } | 225 | } |
226 | 226 | ||
227 | s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), name, len, NULL, 0, 0); | 227 | s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), |
228 | name, len, NULL, 0, 0); | ||
228 | if (s) { | 229 | if (s) { |
229 | bb_error_msg("getnameinfo failed"); | 230 | bb_error_msg("getnameinfo failed"); |
230 | return -1; | 231 | return -1; |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 2c849eb74..08dab26f0 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1254,8 +1254,6 @@ static void win_changed(int nsig) | |||
1254 | 1254 | ||
1255 | int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *st) | 1255 | int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *st) |
1256 | { | 1256 | { |
1257 | static const int null_flags; | ||
1258 | |||
1259 | int lastWasTab = FALSE; | 1257 | int lastWasTab = FALSE; |
1260 | unsigned int ic; | 1258 | unsigned int ic; |
1261 | unsigned char c; | 1259 | unsigned char c; |
@@ -1270,7 +1268,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t | |||
1270 | maxsize = BUFSIZ; | 1268 | maxsize = BUFSIZ; |
1271 | 1269 | ||
1272 | /* With null flags, no other fields are ever used */ | 1270 | /* With null flags, no other fields are ever used */ |
1273 | state = st ? st : (line_input_t*) &null_flags; | 1271 | state = st ? st : (line_input_t*) &const_int_0; |
1274 | if (state->flags & SAVE_HISTORY) | 1272 | if (state->flags & SAVE_HISTORY) |
1275 | load_history(state->hist_file); | 1273 | load_history(state->hist_file); |
1276 | 1274 | ||
diff --git a/libbb/messages.c b/libbb/messages.c index 6c3d2f608..105e4ce66 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -40,6 +40,9 @@ const char bb_path_motd_file[] = "/etc/motd"; | |||
40 | const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; | 40 | const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; |
41 | const char bb_dev_null[] = "/dev/null"; | 41 | const char bb_dev_null[] = "/dev/null"; |
42 | 42 | ||
43 | const int const_int_0; | ||
44 | const int const_int_1 = 1; | ||
45 | |||
43 | #include <utmp.h> | 46 | #include <utmp.h> |
44 | /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ | 47 | /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ |
45 | const char bb_path_wtmp_file[] = | 48 | const char bb_path_wtmp_file[] = |
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 62cab95a1..0addda157 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -9,14 +9,13 @@ | |||
9 | #include <netinet/in.h> | 9 | #include <netinet/in.h> |
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | 11 | ||
12 | static const int one = 1; | ||
13 | int setsockopt_reuseaddr(int fd) | 12 | int setsockopt_reuseaddr(int fd) |
14 | { | 13 | { |
15 | return setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); | 14 | return setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_1, sizeof(const_int_1)); |
16 | } | 15 | } |
17 | int setsockopt_broadcast(int fd) | 16 | int setsockopt_broadcast(int fd) |
18 | { | 17 | { |
19 | return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)); | 18 | return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); |
20 | } | 19 | } |
21 | 20 | ||
22 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) | 21 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) |