Previous 199869 Revisions Next

r35070 Monday 16th February, 2015 at 18:05:45 UTC by Miodrag Milanović
Sync with latest mongoose and added fixes for Mingw compile (nw)
[3rdparty/mongoose]LICENSE README.md mongoose.c
[3rdparty/mongoose/docs]SSL.md
[3rdparty/mongoose/examples/http_client]Makefile

trunk/3rdparty/mongoose/LICENSE
r243581r243582
11Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com>
2Copyright (c) 2013 Cesanta Software Limited
2Copyright (c) 2013-2015 Cesanta Software Limited
33All rights reserved
44
55This code is dual-licensed: you can redistribute it and/or modify
trunk/3rdparty/mongoose/README.md
r243581r243582
7878
7979# Other products by Cesanta Software: simple and effective
8080
81- [Fossa](http://github.com/cesanta/fossa) - Multi-protocol networking library
8182- [SSL Wrapper](https://github.com/cesanta/ssl_wrapper) - application to
8283  secure network communications
8384- [Frozen](https://github.com/cesanta/frozen) - JSON parser and generator
8485- [SLRE](https://github.com/cesanta/slre) - Super Light Regular Expression
8586  library
86- [Net Skeleton](https://github.com/cesanta/net_skeleton) - framework for
87  building network applications
88- [SLDR](https://github.com/cesanta/sldr) - Super Light DNS Resolver
trunk/3rdparty/mongoose/docs/SSL.md
r243581r243582
11# Mongoose SSL guide
22
33SSL is a protocol that makes web communication secure. To enable SSL
4in mongoose, 3 steps are required:
4in mongoose, 2 steps are required:
55
6   1. Valid certificate file must be created
7   2. `ssl_certificate` options must be set to contain path to the
8       certificate file.
9   3. `listening_ports` option must contain a port number with letter `s`
10        appended to it, which instructs Mongoose to use SSL for all connections
11        made to that port.
6   1. Create valid SSL certificate file
7   2. Append SSL certificate file path to the `listening_ports` option
128
139Below is the `mongoose.conf` file snippet for typical SSL setup:
1410
15    document_root     www_root        # Serve files in www_root directory
16    listening_ports   80r,443s        # Redirect all HTTP requests to HTTPS
17    ssl_certificate   ssl_cert.pem    # Location of certificate file
11    document_root     www_root         # Serve files in www_root directory
12    listening_ports   80,443:cert.pem  # Listen on ports 80 and 443
1813
1914## How to create SSL certificate file
2015
trunk/3rdparty/mongoose/examples/http_client/Makefile
r243581r243582
99   $(CC) -o $(PROG) $(SOURCES) $(CFLAGS)
1010
1111clean:
12   rm -rf $(PROG) *.exe *.dSYM *.obj *.exp .*o *.lib
12   rm -rf $(PROG) *.exe *.dSYM *.obj *.exp *.o *.lib
trunk/3rdparty/mongoose/mongoose.c
r243581r243582
4848#define _INTEGRAL_MAX_BITS 64   // Enable _stati64() on Windows
4949#define _CRT_SECURE_NO_WARNINGS // Disable deprecation warning in VS2005+
5050#undef WIN32_LEAN_AND_MEAN      // Let windows.h always include winsock2.h
51#ifdef __Linux__
51#if defined(__Linux__) || defined(_WIN32)
5252#define _XOPEN_SOURCE 600       // For flockfile() on Linux
5353#endif
5454#define __STDC_FORMAT_MACROS    // <inttypes.h> wants this for C++
r243581r243582
347347  assert(io != NULL);
348348  assert(io->len <= io->size);
349349
350  /* check overflow */
351  if (len > ~(size_t)0 - (size_t)(io->buf + io->len)) {
352    return 0;
353  }
354
350355  if (len <= 0) {
351356  } else if (io->len + len <= io->size) {
352357    memcpy(io->buf + io->len, buf, len);
r243581r243582
28932898static int deliver_websocket_frame(struct connection *conn) {
28942899  // Having buf unsigned char * is important, as it is used below in arithmetic
28952900  unsigned char *buf = (unsigned char *) conn->ns_conn->recv_iobuf.buf;
2896  int i, len, buf_len = conn->ns_conn->recv_iobuf.len, frame_len = 0,
2901  size_t i, len, buf_len = conn->ns_conn->recv_iobuf.len, frame_len = 0,
28972902      mask_len = 0, header_len = 0, data_len = 0, buffered = 0;
28982903
28992904  if (buf_len >= 2) {
r243581r243582
29042909      header_len = 2 + mask_len;
29052910    } else if (len == 126 && buf_len >= 4 + mask_len) {
29062911      header_len = 4 + mask_len;
2907      data_len = ((((int) buf[2]) << 8) + buf[3]);
2912      data_len = ((((size_t) buf[2]) << 8) + buf[3]);
29082913    } else if (buf_len >= 10 + mask_len) {
29092914      header_len = 10 + mask_len;
2910      data_len = (int) (((uint64_t) htonl(* (uint32_t *) &buf[2])) << 32) +
2915      data_len = (size_t) (((uint64_t) htonl(* (uint32_t *) &buf[2])) << 32) +
29112916        htonl(* (uint32_t *) &buf[6]);
29122917    }
29132918  }
r243581r243582
29382943}
29392944
29402945size_t mg_websocket_write(struct mg_connection *conn, int opcode,
2941                       const char *data, size_t data_len) {
2946                          const char *data, size_t data_len) {
29422947    unsigned char mem[4192], *copy = mem;
29432948    size_t copy_len = 0;
29442949
2950    /* Check overflow */
2951    if (data_len > ~(size_t)0 - (size_t)10) {
2952      return 0;
2953    }
2954
29452955    if (data_len + 10 > sizeof(mem) &&
29462956        (copy = (unsigned char *) NS_MALLOC(data_len + 10)) == NULL) {
29472957      return 0;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team