Skip to content

Commit e8863a0

Browse files
committed
Updating Civetweb
1 parent 09cfb56 commit e8863a0

File tree

2 files changed

+55
-20
lines changed

2 files changed

+55
-20
lines changed

src/civetweb/civetweb.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
183183
#error "Symbian is no longer maintained. CivetWeb no longer supports Symbian."
184184
#endif /* __SYMBIAN32__ */
185185

186+
#if defined(__rtems__)
187+
#include <rtems/version.h>
188+
#endif
189+
186190
#if defined(__ZEPHYR__)
187191
#include <ctype.h>
188192
#include <fcntl.h>
@@ -885,7 +889,9 @@ typedef unsigned short int in_port_t;
885889
#include <string.h>
886890
#include <sys/socket.h>
887891
#include <sys/time.h>
892+
#if !defined(__rtems__)
888893
#include <sys/utsname.h>
894+
#endif
889895
#include <sys/wait.h>
890896
#include <time.h>
891897
#include <unistd.h>
@@ -901,8 +907,22 @@ typedef unsigned short int in_port_t;
901907
#endif
902908

903909
#if defined(__MACH__) && defined(__APPLE__)
904-
#define SSL_LIB "libssl.dylib"
905-
#define CRYPTO_LIB "libcrypto.dylib"
910+
911+
#if defined(OPENSSL_API_3_0)
912+
#define SSL_LIB "libssl.3.dylib"
913+
#define CRYPTO_LIB "libcrypto.3.dylib"
914+
#endif
915+
916+
#if defined(OPENSSL_API_1_1)
917+
#define SSL_LIB "libssl.1.1.dylib"
918+
#define CRYPTO_LIB "libcrypto.1.1.dylib"
919+
#endif /* OPENSSL_API_1_1 */
920+
921+
#if defined(OPENSSL_API_1_0)
922+
#define SSL_LIB "libssl.1.0.dylib"
923+
#define CRYPTO_LIB "libcrypto.1.0.dylib"
924+
#endif /* OPENSSL_API_1_0 */
925+
906926
#else
907927
#if !defined(SSL_LIB)
908928
#define SSL_LIB "libssl.so"
@@ -963,7 +983,7 @@ count_leap(int y)
963983
return (y - 1969) / 4 - (y - 1901) / 100 + (y - 1601) / 400;
964984
}
965985

966-
time_t
986+
static time_t
967987
timegm(struct tm *tm)
968988
{
969989
static const unsigned short ydays[] = {
@@ -19532,6 +19552,9 @@ mg_connect_websocket_client(const char *host,
1953219552
memset(&client_options, 0, sizeof(client_options));
1953319553
client_options.host = host;
1953419554
client_options.port = port;
19555+
if (use_ssl) {
19556+
client_options.host_name = host;
19557+
}
1953519558

1953619559
return mg_connect_websocket_client_impl(&client_options,
1953719560
use_ssl,
@@ -20786,6 +20809,8 @@ get_system_name(char **sysName)
2078620809

2078720810
*sysName = mg_strdup(name);
2078820811

20812+
#elif defined(__rtems__)
20813+
*sysName = mg_strdup("RTEMS");
2078920814
#elif defined(__ZEPHYR__)
2079020815
*sysName = mg_strdup("Zephyr OS");
2079120816
#else
@@ -22079,13 +22104,23 @@ mg_get_system_info(char *buffer, int buflen)
2207922104
(unsigned)si.dwNumberOfProcessors,
2208022105
(unsigned)si.dwActiveProcessorMask);
2208122106
system_info_length += mg_str_append(&buffer, end, block);
22082-
#elif defined(__ZEPHYR__)
22107+
#elif defined(__rtems__)
2208322108
mg_snprintf(NULL,
2208422109
NULL,
2208522110
block,
2208622111
sizeof(block),
2208722112
",%s\"os\" : \"%s %s\"",
2208822113
eol,
22114+
"RTEMS",
22115+
rtems_version());
22116+
system_info_length += mg_str_append(&buffer, end, block);
22117+
#elif defined(__ZEPHYR__)
22118+
mg_snprintf(NULL,
22119+
NULL,
22120+
block,
22121+
sizeof(block),
22122+
",%s\"os\" : \"%s\"",
22123+
eol,
2208922124
"Zephyr OS",
2209022125
ZEPHYR_VERSION);
2209122126
system_info_length += mg_str_append(&buffer, end, block);

src/civetweb/handle_form.inl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ mg_handle_form_request(struct mg_connection *conn,
188188
char path[512];
189189
char buf[MG_BUF_LEN]; /* Must not be smaller than ~900 */
190190
int field_storage;
191-
int buf_fill = 0;
191+
size_t buf_fill = 0;
192192
int r;
193193
int field_count = 0;
194194
struct mg_file fstore = STRUCT_FILE_INITIALIZER;
@@ -397,10 +397,10 @@ mg_handle_form_request(struct mg_connection *conn,
397397
int end_of_key_value_pair_found = 0;
398398
int get_block;
399399

400-
if ((size_t)buf_fill < (sizeof(buf) - 1)) {
400+
if (buf_fill < (sizeof(buf) - 1)) {
401401

402-
size_t to_read = sizeof(buf) - 1 - (size_t)buf_fill;
403-
r = mg_read(conn, buf + (size_t)buf_fill, to_read);
402+
size_t to_read = sizeof(buf) - 1 - buf_fill;
403+
r = mg_read(conn, buf + buf_fill, to_read);
404404
if ((r < 0) || ((r == 0) && all_data_read)) {
405405
/* read error */
406406
return -1;
@@ -529,11 +529,11 @@ mg_handle_form_request(struct mg_connection *conn,
529529
buf + (size_t)used,
530530
sizeof(buf) - (size_t)used);
531531
next = buf;
532-
buf_fill -= (int)used;
533-
if ((size_t)buf_fill < (sizeof(buf) - 1)) {
532+
buf_fill -= used;
533+
if (buf_fill < (sizeof(buf) - 1)) {
534534

535-
size_t to_read = sizeof(buf) - 1 - (size_t)buf_fill;
536-
r = mg_read(conn, buf + (size_t)buf_fill, to_read);
535+
size_t to_read = sizeof(buf) - 1 - buf_fill;
536+
r = mg_read(conn, buf + buf_fill, to_read);
537537
if ((r < 0) || ((r == 0) && all_data_read)) {
538538
#if !defined(NO_FILESYSTEMS)
539539
/* read error */
@@ -592,7 +592,7 @@ mg_handle_form_request(struct mg_connection *conn,
592592
/* Proceed to next entry */
593593
used = next - buf;
594594
memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used);
595-
buf_fill -= (int)used;
595+
buf_fill -= used;
596596
}
597597

598598
return field_count;
@@ -682,12 +682,12 @@ mg_handle_form_request(struct mg_connection *conn,
682682
for (part_no = 0;; part_no++) {
683683
size_t towrite, fnlen, n;
684684
int get_block;
685-
size_t to_read = sizeof(buf) - 1 - (size_t)buf_fill;
685+
size_t to_read = sizeof(buf) - 1 - buf_fill;
686686

687687
/* Unused without filesystems */
688688
(void)n;
689689

690-
r = mg_read(conn, buf + (size_t)buf_fill, to_read);
690+
r = mg_read(conn, buf + buf_fill, to_read);
691691
if ((r < 0) || ((r == 0) && all_data_read)) {
692692
/* read error */
693693
mg_free(boundary);
@@ -1001,12 +1001,12 @@ mg_handle_form_request(struct mg_connection *conn,
10011001
#endif /* NO_FILESYSTEMS */
10021002

10031003
memmove(buf, hend + towrite, bl + 4);
1004-
buf_fill = (int)(bl + 4);
1004+
buf_fill = bl + 4;
10051005
hend = buf;
10061006

10071007
/* Read new data */
1008-
to_read = sizeof(buf) - 1 - (size_t)buf_fill;
1009-
r = mg_read(conn, buf + (size_t)buf_fill, to_read);
1008+
to_read = sizeof(buf) - 1 - buf_fill;
1009+
r = mg_read(conn, buf + buf_fill, to_read);
10101010
if ((r < 0) || ((r == 0) && all_data_read)) {
10111011
#if !defined(NO_FILESYSTEMS)
10121012
/* read error */
@@ -1025,7 +1025,7 @@ mg_handle_form_request(struct mg_connection *conn,
10251025
/* buf_fill is at least 8 here */
10261026

10271027
/* Find boundary */
1028-
next = search_boundary(buf, (size_t)buf_fill, boundary, bl);
1028+
next = search_boundary(buf, buf_fill, boundary, bl);
10291029

10301030
if (!next && (r == 0)) {
10311031
/* incomplete request */
@@ -1100,7 +1100,7 @@ mg_handle_form_request(struct mg_connection *conn,
11001100
if (next) {
11011101
used = next - buf + 2;
11021102
memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used);
1103-
buf_fill -= (int)used;
1103+
buf_fill -= used;
11041104
} else {
11051105
buf_fill = 0;
11061106
}

0 commit comments

Comments
 (0)