Skip to content

Commit a4b51e6

Browse files
flichtenheldcron2
authored andcommitted
manage: Avoid several conversion warnings by using the correct types
Change-Id: I0c5ef13d6fa6c1dd15da934a33e904c2fdacb731 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1438 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg35077.html Signed-off-by: Gert Doering <[email protected]>
1 parent 5e5ead5 commit a4b51e6

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

src/openvpn/manage.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,6 @@ man_password_needed(struct management *man)
206206
return man->settings.up.defined && !man->connection.password_verified;
207207
}
208208

209-
#if defined(__GNUC__) || defined(__clang__)
210-
#pragma GCC diagnostic push
211-
#pragma GCC diagnostic ignored "-Wconversion"
212-
#endif
213-
214209
static void
215210
man_check_password(struct management *man, const char *line)
216211
{
@@ -220,7 +215,8 @@ man_check_password(struct management *man, const char *line)
220215
* the attacker choice, it should not give any indication of the real
221216
* password length, use + 1 to include the NUL byte that terminates the
222217
* string*/
223-
size_t compare_len = min_uint(strlen(line) + 1, sizeof(man->settings.up.password));
218+
size_t compare_len =
219+
min_size(strlen(line) + 1, sizeof(man->settings.up.password));
224220
if (memcmp_constant_time(line, man->settings.up.password, compare_len) == 0)
225221
{
226222
man->connection.password_verified = true;
@@ -241,10 +237,6 @@ man_check_password(struct management *man, const char *line)
241237
}
242238
}
243239

244-
#if defined(__GNUC__) || defined(__clang__)
245-
#pragma GCC diagnostic pop
246-
#endif
247-
248240
static void
249241
man_update_io_state(struct management *man)
250242
{
@@ -2315,19 +2307,14 @@ managment_android_persisttun_action(struct management *man)
23152307

23162308
#endif /* ifdef TARGET_ANDROID */
23172309

2318-
#if defined(__GNUC__) || defined(__clang__)
2319-
#pragma GCC diagnostic push
2320-
#pragma GCC diagnostic ignored "-Wconversion"
2321-
#endif
2322-
2323-
static int
2310+
static ssize_t
23242311
man_read(struct management *man)
23252312
{
23262313
/*
23272314
* read command line from socket
23282315
*/
23292316
unsigned char buf[256];
2330-
int len = 0;
2317+
ssize_t len = 0;
23312318

23322319
#ifdef TARGET_ANDROID
23332320
int fd;
@@ -2348,7 +2335,7 @@ man_read(struct management *man)
23482335
{
23492336
bool processed_command = false;
23502337

2351-
ASSERT(len <= (int)sizeof(buf));
2338+
ASSERT(len <= (ssize_t)sizeof(buf));
23522339
command_line_add(man->connection.in, buf, (size_t)len);
23532340

23542341
/*
@@ -2414,11 +2401,11 @@ man_read(struct management *man)
24142401
return len;
24152402
}
24162403

2417-
static int
2404+
static ssize_t
24182405
man_write(struct management *man)
24192406
{
24202407
const int size_hint = 1024;
2421-
int sent = 0;
2408+
ssize_t sent = 0;
24222409
const struct buffer *buf;
24232410

24242411
buffer_list_aggregate(man->connection.out, size_hint);
@@ -2435,7 +2422,9 @@ man_write(struct management *man)
24352422
}
24362423
else
24372424
#endif
2425+
{
24382426
sent = send(man->connection.sd_cli, (const void *)BPTR(buf), len, MSG_NOSIGNAL);
2427+
}
24392428
if (sent >= 0)
24402429
{
24412430
buffer_list_advance(man->connection.out, sent);
@@ -2457,10 +2446,6 @@ man_write(struct management *man)
24572446
return sent;
24582447
}
24592448

2460-
#if defined(__GNUC__) || defined(__clang__)
2461-
#pragma GCC diagnostic pop
2462-
#endif
2463-
24642449
static void
24652450
man_connection_clear(struct man_connection *mc)
24662451
{
@@ -3222,8 +3207,7 @@ management_io(struct management *man)
32223207

32233208
if (net_events & FD_WRITE)
32243209
{
3225-
int status;
3226-
status = man_write(man);
3210+
ssize_t status = man_write(man);
32273211
if (status < 0 && WSAGetLastError() == WSAEWOULDBLOCK)
32283212
{
32293213
net_event_win32_clear_selected_events(&man->connection.ne32, FD_WRITE);

0 commit comments

Comments
 (0)