Coder Social home page Coder Social logo

freecoap's People

Contributors

keith-cullen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freecoap's Issues

Bug: Misaligned Address Load Detected in coap_msg.c at coap_msg_parse_op Function

Reproduce Info

version:v0.7

Build Environment Update

The Makefile within the test_coap_server directory have been updated to utilize clang with sanitizers.

 I1 = ../../lib/include
 S1 = ../../lib/src
-CC_ ?= gcc
-CFLAGS = -Wall \
+CC_ ?= clang
+CFLAGS = -Wall -g -fsanitize=address,undefined -fno-omit-frame-pointer\
          -I $(I1)
 CFLAGS += $(IP6_CFLAGS)
 CFLAGS += $(DTLS_CFLAGS)
-LD_ ?= gcc
-LDFLAGS =
+LD_ ?= clang
+LDFLAGS = -fsanitize=address,undefined
 INCS = $(I1)/coap_server.h \
        $(I1)/coap_msg.h \
        $(I1)/coap_mem.h \

Building test_coap_server

cd FreeCoAP/test/test_coap_server
make dtls=n

Run Instructions

Starting the CoAP Server

The CoAP server was started using the test_coap_server executable:

cd FreeCoAP/test/test_coap_server
./test_coap_server

Sending a Packet

The packet was sent to the server using the following command:

echo -n "4001a9a889e6e689e689e689e689e689e60ad0f4b7726567756c6172" | xxd -r -p | nc -u 0.0.0.0 12436

The packet's structure is as follows:

  • Version: 1
  • Type: Confirmable (CON)
  • Token Length: 16
  • Code: GET
  • Message ID: 43432
  • Token: 0x89 0xe6 0xe6 0x89 0xe6 0x89 0xe6 0x89 0xe6 0x89 0xe6 0x0a 0xd0 0xf4
  • Options: Uri-Path: 'regular'
  • Payload: None

The hex representation of the datagram sent to the server is as follows:

4001a9a889e6e689e689e689e689e689e60ad0f4b7726567756c6172

Description

UndefinedBehaviorSanitizer has detected an issue where a misaligned address is loaded for a uint16_t type, which requires 2-byte alignment. This issue occurs within the coap_msg_parse_op function.

Crash report

Here is the UBSan report:

FreeCoAP/test/test_coap_server/lib/src/coap_msg.c:579:32: runtime error: load of misaligned address for type 'uint16_t' (aka 'unsigned short'), which requires 2 byte alignment
 89 e6 89 e6 89 e6 0a d0 f4 b7 72 65 67 75 6c 61 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
             ^ 
[Backtrace]
    #0 0x4efde9 in coap_msg_parse_op FreeCoAP/lib/src/coap_msg.c:579:32
    #1 0x4e9eb5 in coap_msg_parse_ops FreeCoAP/lib/src/coap_msg.c:647:15
    #2 0x4e8934 in coap_msg_parse FreeCoAP/lib/src/coap_msg.c:744:11
    #3 0x4e0031 in coap_server_trans_recv FreeCoAP/lib/src/coap_server.c:1089:11
    #4 0x4d9ac5 in coap_server_exchange FreeCoAP/lib/src/coap_server.c:2285:11
    #5 0x4d7c1f in coap_server_run FreeCoAP/lib/src/coap_server.c:2559:15
    #6 0x4c8b95 in main FreeCoAP/test/test_coap_server/test_coap_server.c:747:11
    #7 0x7f9ff32430b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #8 0x41c36d in _start (FreeCoAP/test/test_coap_server/test_coap_server+0x41c36d)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior FreeCoAP/test/test_coap_server/lib/src/coap_msg.c:579:32 in

Test on Intel Galileo Gen 1

I want to try FreeCoAP (client only) on Intel Galileo Gen 1 (I saw that you test it). How to install GnuTLS on this board? Any other dependencies?
Or is necessary a cross compilation?
Thanks

question about coap_mem / samples

Hi, should I use coap_mem in user code?
I saw that make install will not include coap_mem.h, but the samples use it (transfer_server).
Also the symbols used by coap_mem are not exported.

Do I have to use coap_mem_all_create / coap_mem_all_destory and if so how?

lib/Makefile:336
  include_HEADERS = include/coap_msg.h include/coap_log.h include/coap_client.h include/coap_server.h include/coap_ipv.h
When I copy the header over:
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_small_alloc'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_medium_get_len'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_large_get_len'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_small_get_len'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_small_free'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_medium_alloc'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_large_alloc'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_large_free'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_medium_free'

Proxy selection

How do you select forward or reverse proxy node in the FreeCoAP
Is it pre-selected or dynamically choosen

test_http_client

user@instant-contiki:/Desktop/FreeCoAP-master/FreeCoAP-master/test/test_http_client$ make ip6=y
make: `test_http_client' is up to date.
user@instant-contiki:
/Desktop/FreeCoAP-master/FreeCoAP-master/test/test_http_client$ ./test_http_client
Error : unable to load TLS credentials
user@instant-contiki:/Desktop/FreeCoAP-master/FreeCoAP-master/test/test_http_client$ make clean
/bin/rm -f test_http_client test_http_client.o http_msg.o tls.o sock.o tls_sock.o data_buf.o util.o coap_log.o test.o
user@instant-contiki:
/Desktop/FreeCoAP-master/FreeCoAP-master/test/test_http_client$ make ip6=y
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c test_http_client.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../proxy/common/src/http_msg.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../proxy/common/src/tls.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../proxy/common/src/sock.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../proxy/common/src/tls_sock.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../proxy/common/src/data_buf.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../proxy/common/src/util.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../../lib/src/coap_log.c
gcc -DSOCK_IP6 -Wall -I../../lib/include -I../../proxy/common/include -I.. -DTLS_CLIENT_AUTH -c ../test.c
gcc test_http_client.o http_msg.o tls.o sock.o tls_sock.o data_buf.o util.o coap_log.o test.o -o test_http_client -lpthread -lgnutls -lnettle -lhogweed -lgmp
user@instant-contiki:~/Desktop/FreeCoAP-master/FreeCoAP-master/test/test_http_client$ ./test_http_client
Error : unable to load TLS credentials

Disabling DTLS on COAP side in proxy applications

Hi
I have removed a DCOAP_DTLS_EN flag from the proxy make file and bullied the test_coap_server with dtls=n. But when I tried to build the proxy I got the following error:
"too many arguments to the function coap_client_create"
Can you please say what changes should I need to do in order to replace call to coap_client_create in proxy/http_coap/src/connection.c with non-DTLS version

GnuTLS for DTLS on Intel Galileo

I don't understand how to install gnutls on Intel Galileo. I understand that cross-compilation should be used but I haven't been able to compile gnutls and all the other dependences needed to compile FreeeCoAP. Can you help me? Sorry for my many question but I use your client (simple version) for send requests to authorization server written in Golang. On my PC that works. But now I won't test this on Galileo (only client side)

Bug: Null Pointer Dereference Detected in test_coap_server.c at server_handle_regular Function

Reproduce Info

Build Environment Update

The Makefile within the test_coap_server directory have been updated to utilize clang with sanitizers.

 I1 = ../../lib/include
 S1 = ../../lib/src
-CC_ ?= gcc
-CFLAGS = -Wall \
+CC_ ?= clang
+CFLAGS = -Wall -g -fsanitize=address,undefined -fno-omit-frame-pointer\
          -I $(I1)
 CFLAGS += $(IP6_CFLAGS)
 CFLAGS += $(DTLS_CFLAGS)
-LD_ ?= gcc
-LDFLAGS =
+LD_ ?= clang
+LDFLAGS = -fsanitize=address,undefined
 INCS = $(I1)/coap_server.h \
        $(I1)/coap_msg.h \
        $(I1)/coap_mem.h \

Building test_coap_server

cd FreeCoAP/test/test_coap_server
make dtls=n

Run Instructions

Starting the CoAP Server

The CoAP server was started using the test_coap_server executable:

cd FreeCoAP/test/test_coap_server
./test_coap_server

Sending a Packet

The packet was sent to the server using the following command:

echo -n "4402c6347d0fbbf3bd05657565756575657565756575657565756575" | xxd -r -p | nc -u 0.0.0.0 12436

The packet's structure is as follows:

  • ver = 1
  • type = CON
  • tkl = 4
  • code = POST
  • msg_id = 50740
  • token = '}\x0f\xbb\xf3'
  • options = [('Uri-Path', b'eueueueueueueueueu')]
  • paymark = ''

The hex representation of the datagram sent to the server is as follows:

4402c6347d0fbbf3bd05657565756575657565756575657565756575

Description

The server application encountered a runtime error detected by UndefinedBehaviorSanitizer (UBSan) during the execution of routine tasks. UBSan identified a null pointer being passed as the second argument to the memcpy function, which is explicitly declared to never accept a null pointer according to the annotations in string.h. The specific error was reported within the server_handle_regular function of test_coap_server.c.

Crash report

log of server:

Info   : Received confirmable request from address 127.0.0.1 and port 58854
Info   : Request URI path requires a piggy-backed response to address 127.0.0.1 and port 58854
Info   : Responding to address 127.0.0.1 and port 58854
Notice : handle regular
Received:
ver:         0x01
type:        0x00
token_len:   4
code_class:  0
code_detail: 1
msg_id:      0x26c4
token:       0x88 0x18 0x8c 0x3d
op[0].num:   11
op[0].len:   7
op[0].val:   0x72 0x65 0x67 0x75 0x6c 0x61 0x72
payload:     
payload_len: 0
Sent: 
ver:         0x01
type:        0x00
token_len:   0
code_class:  2
code_detail: 5
msg_id:      0x0000
token:      
payload:     qwertyuiopasdfgh
payload_len: 16

Here is the UBSan report:

test_coap_server.c:361:29: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
    #0 0x4cb239 in server_handle_regular FreeCoAP/test/test_coap_server/test_coap_server.c:361:9
    #1 0x4c8e1b in server_handle FreeCoAP/test/test_coap_server/test_coap_server.c:616:15
    #2 0x4db596 in coap_server_exchange FreeCoAP/lib/src/coap_server.c:2440:15
    #3 0x4d7c1f in coap_server_run FreeCoAP/lib/src/coap_server.c:2559:15
    #4 0x4c8b95 in main FreeCoAP/test/test_coap_server/test_coap_server.c:747:11
    #5 0x7fa12859d0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #6 0x41c36d in _start (FreeCoAP/test/test_coap_server/test_coap_server+0x41c36d)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test_coap_server.c:361:29 in 

proxy and other questions

Hi.

I've Problems with the proxy test. All other tests pass 100% while
proxy fails all the time. Seems to be some more general unix related
problem, cause the proxy is not permitted to use the coap-client, but
I don't know to solve this issue.

AND

As my first question already revealed, I'm not an expert but trying my best.
To do this there would be some community very delightful. Is there any?

btw:
Thx for your great work. I think CoAP is a relatively young but attractive
protocol and for know I allready saw some implementations which where
nice but a unix based implementaion is just awesome!

cURL example of test http client

Good day

I have successfully implemented the HTTP/CoAP proxy application with the HTTP/TLS/IPv4 and CoAP/DTLS/IPv6 example as described in the README, however I would like to replace test_http_client with a standard cURL call. Will this be possible? I have made some progress and can successfully establish a https (tls) connection to the proxy from cURL by using the -k, --key, --cacert and --cert flags together with https://127.0.0.1:12437, however I am not sure where or how to specify the "POST coaps://[::1]:12436/resource" request string in cURL. Can you perhaps provide some guidence or an example?

Any help would be greatly appreciated.
Regards

function coap_server_get_resp_type have a bug

when uri is "/22222/123", this function can't match, the buf is "/22222/12322".
patch:

Index: free_coap_lib/src/coap_server.c
===================================================================
--- free_coap_lib/src/coap_server.c	(revision 931)
+++src/coap_server.c	(working copy)
@@ -1831,6 +1831,11 @@
     {
         buf[0] = '/';
     }
+    else
+    {
+        *p = '\0';
+    }
+    printf("[llm] %s(%d)buf = %s\n", __FUNCTION__, __LINE__, buf);
     match = coap_server_path_list_match(&server->sep_list, buf);
     return match ? COAP_SERVER_SEPARATE : COAP_SERVER_PIGGYBACKED;
 }

unable to run test applications

I am running ubuntu 17.04 machine inside a virtual box 5.1.22.
I have created 6lowpan interfaces in separate namespaces using Linux fakelb modules.
I want to run test_coap_server applications on the 6lowpan interfaces which have been created.
I want to run the test_coap_client applications in the global namespace i.e. on the enp0s3 interface in my case.
I am able to run the server successfully without any errors on the 6lowpan interface but when I am running the test_client applications, the system hangs up and doesn't respond at all. I have waited for an hour and see no improvement.I have debugged both the applications, the client application hangs up at line 1292.
I wonder what's the problem?
can I solve this?
can the server run on the 6lowpan interface?

running failed under mips system

I tested it under Ubuntu system ,the programming generate client application,it works well under Ubuntu system .
but ,when porting this program to mips CPU(base on Linux 2.6 kernel),encounted error as below:
/usr/sbin/client: line 1: syntax error: unexpected word (expecting ")")

to check executable program formate by file command:
#file client
client: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xf6825841efc4c945b433e12929202a3879bd2b40, not stripped

so the probem is that my hardware is MIPS ,but the generated excutable application is Inter 80386,how can let this code works on MIPS system?
here is another formate excutable application as bellow:
#file appMng
appMng: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, stripped
it works well on my MIPS system

Piggy-backed response

Hi Keith,
I'm having problems attaching a payload to an Ack message i.e. a piggy-backed response. When checking the coap_server_exchange function I cannot find the lines that set the payload for the Ack.
Can you please tell how I can achieve this?
Kind regards,
Dorus

IP Address Problem

I have modified the IPv6 to IPv4. But how can I set the local IP address?
In IPv6, we can use "::1". How about IPv4?
Thanks.

Bug: global-buffer-overflow on test_coap_server.c:server_handle_reset

Build

Build the test_coap_server with ASAN flag

export CFLAGS=-Wall -g fsanitize=address
make dtls=n

Run

Run test_coap_server and test_coap_client in two terminal

Analyze

A global-buffer-overflow happend on memcpy(app_level_blockwise_buf, app_level_blockwise_def_val, sizeof(app_level_blockwise_buf));.
sizeof(app_level_blockwise_buf is 40, but the app_level_blockwise_def_val point to ""

/**
 *  @brief Buffer used for application-level blockwise transfers
 */
static char *app_level_blockwise_def_val = "";
static char app_level_blockwise_buf[APP_LEVEL_BLOCKWISE_BUF_LEN] = {0};
...

static int server_handle_reset(coap_server_trans_t *trans, coap_msg_t *req, coap_msg_t *resp)
{
    coap_log_notice("Resetting to a known state");

    memset(regular_buf, 0, sizeof(regular_buf));
    memcpy(regular_buf, regular_def_val, sizeof(regular_buf));

    memset(app_level_blockwise_buf, 0, sizeof(app_level_blockwise_buf));
    memcpy(app_level_blockwise_buf, app_level_blockwise_def_val, sizeof(app_level_blockwise_buf)); // global-buffer-overflow

    memset(lib_level_blockwise_buf, 0, sizeof(lib_level_blockwise_buf));
    memcpy(lib_level_blockwise_buf, lib_level_blockwise_def_val, sizeof(lib_level_blockwise_buf));

    return coap_msg_set_code(resp, COAP_MSG_SUCCESS, COAP_MSG_CONTENT);
}

ASAN Log

==2889303==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000004f6581 at pc 0x0000004958c7 bp 0x7ffe84583650 sp 0x7ffe84582e18
READ of size 40 at 0x0000004f6581 thread T0
    #0 0x4958c6 in __asan_memcpy (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4958c6)
    #1 0x4c6c21 in server_handle_reset (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4c6c21)
    #2 0x4c66aa in server_handle (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4c66aa)
    #3 0x4d2543 in coap_server_exchange (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4d2543)
    #4 0x4d0071 in coap_server_run (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4d0071)
    #5 0x4c64c2 in main (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4c64c2)
    #6 0x7f3e50eb0082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41c3fd in _start (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x41c3fd)

0x0000004f6581 is located 63 bytes to the left of global variable '<string literal>' defined in 'test_coap_server.c:96:44' (0x4f65c0) of size 73
  '<string literal>' is ascii string '0123456789abcdefghijABCDEFGHIJasdfghjklpqlfktnghrexi49s1zlkdfiecvntfbghq'
0x0000004f6581 is located 0 bytes to the right of global variable '<string literal>' defined in 'test_coap_server.c:90:44' (0x4f6580) of size 1
  '<string literal>' is ascii string ''
SUMMARY: AddressSanitizer: global-buffer-overflow (/home/user/FreeCoAP/test/test_coap_server/test_coap_server+0x4958c6) in __asan_memcpy
Shadow bytes around the buggy address:
  0x000080096c60: 00 07 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x000080096c70: 07 f9 f9 f9 f9 f9 f9 f9 00 00 00 03 f9 f9 f9 f9
  0x000080096c80: 00 00 03 f9 f9 f9 f9 f9 00 00 00 06 f9 f9 f9 f9
  0x000080096c90: 00 00 00 00 00 02 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x000080096ca0: 00 02 f9 f9 f9 f9 f9 f9 00 00 01 f9 f9 f9 f9 f9
=>0x000080096cb0:[01]f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x000080096cc0: 00 01 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 05 f9
  0x000080096cd0: f9 f9 f9 f9 00 00 00 00 00 00 00 02 f9 f9 f9 f9
  0x000080096ce0: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 06 f9 f9 f9
  0x000080096cf0: f9 f9 f9 f9 00 00 00 00 00 06 f9 f9 f9 f9 f9 f9
  0x000080096d00: 00 00 00 00 00 02 f9 f9 f9 f9 f9 f9 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==2889303==ABORTING

problem implementing ipv6

Hello,
I am trying to run test_coap_server using the following commands,
make ip6=y dtls=n .
Successfully installed the required packages.
Running on a Ubuntu 17.04 machine in a virtual box .
Getting an error : device or resource busy.
But on the specified port in the script no other processes are running.
How should we solve this?

Bug: Null Pointer Dereference Detected in coap_client.c at coap_client_exchange_blockwise2 Function

Reproduce Info

Build Environment Update

The Makefile within the test_coap_server directory has been updated to utilize clang with sanitizers.

 I1 = ../../lib/include
 S1 = ../../lib/src
-CC_ ?= gcc
-CFLAGS = -Wall \
+CC_ ?= clang
+CFLAGS = -Wall -g -fsanitize=address,undefined -fno-omit-frame-pointer\
          -I $(I1)
 CFLAGS += $(IP6_CFLAGS)
 CFLAGS += $(DTLS_CFLAGS)
-LD_ ?= gcc
-LDFLAGS =
+LD_ ?= clang
+LDFLAGS = -fsanitize=address,undefined
 INCS = $(I1)/coap_server.h \
        $(I1)/coap_msg.h \
        $(I1)/coap_mem.h \

Building test_coap_server

cd FreeCoAP/test/test_coap_server
make dtls=n

Run Instructions

Starting the CoAP Server

The CoAP server was started using the test_coap_server executable:

cd FreeCoAP/test/test_coap_server
./test_coap_server 1234

Sending the Packet

Sending packets from the client to the client using a series of hexstreams in:
hexstream.txt

Description

A null pointer dereference issue was discovered in coap_client_exchange_blockwise2 function defined in coap_client.c at line 1950. The function coap_msg_get_payload(resp) returns a null pointer which is then passed to memcpy as the source argument, leading to undefined behavior as specified by the C standard.

Crash report

Here is the UBSan report:

../../lib/src/coap_client.c:1950:37: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
    #0 0x4d738c in coap_client_exchange_blockwise2 FreeCoAP/test/test_coap_client/../../lib/src/coap_client.c:1950:9
    #1 0x4d5c7b in coap_client_exchange_blockwise FreeCoAP/test/test_coap_client/../../lib/src/coap_client.c:1976:15
    #2 0x4d1750 in exchange_blockwise FreeCoAP/test/test_coap_client/test_coap_client.c:2316:11
    #3 0x4cbb9f in test_exchange_blockwise_func FreeCoAP/test/test_coap_client/test_coap_client.c:2635:15
    #4 0x4ef7df in test_run FreeCoAP/test/test_coap_client/../test.c:51:18
    #5 0x4c9acc in main FreeCoAP/test/test_coap_client/test_coap_client.c:2963:20
    #6 0x7f596c2d20b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41c35d in _start (FreeCoAP/test/test_coap_client/test_coap_client+0x41c35d)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../lib/src/coap_client.c:1950:37 in 

Running test_http_clent

every time i try to run http_client i get the following error
user@instant-contiki:~/Desktop/FreeCoAP-master/FreeCoAP-master/test/test_http_client$ ./test_http_client
Error : unable to load TLS credentials
please help

Concurrency

Hi,
The more simultaneous coap client connections are managed by coap server?

proxy applications

How to proxy test applications without TLS/DTLS support?
How to run proxy test application with TLS on the side and without DTLS on the other side?

second request can't recv data

I write a server, but I find a problem, when client second request , my server response empty mseeage.

log:
Debug : Sent to address 192.168.242.10 and port 50833
Debug : Found existing transaction at index 0
Debug : Received from address 192.168.242.10 and port 50833
Info : Received confirmable request from address 192.168.242.10 and port 50833
Info : Request URI path requires a piggy-backed response to address 192.168.242.10 and port 50833
Info : Responding to address 192.168.242.10 and port 50833

why print "Found existing transaction at index 0"?

Missing license file

I am looking at using your library for a project but need to have a license to check it is compatible with our project. All I can find is the following:

Released under a BSD style license.

Would you be able to include a full license with your project?

Thanks,

Mike

I have some question about how to build your proxy code

Hello,
I have some question about your code 'HTTP/CoAP proxy application with TLS and DTLS'.
I put the "make" commnad in 'test coap server folder'(../test/test_coap_server)
and some error occured in terminal like below.


../test/test_coap_server# make
gcc test_coap_server.o coap_server.o coap_msg.o coap_log.o -o test_coap_server -lgmp -lhogweed -lnettle -lgnutls
coap_server.o: In function coap_server_trans_dtls_create': /root/CoAP-P/test/test_coap_server/../../lib/src/coap_server.c:429: undefined reference tognutls_transport_set_pull_timeout_function'
/root/CoAP-P/test/test_coap_server/../../lib/src/coap_server.c:431: undefined reference to gnutls_dtls_set_mtu' /root/CoAP-P/test/test_coap_server/../../lib/src/coap_server.c:432: undefined reference tognutls_dtls_set_timeouts'
collect2: error: ld returned 1 exit status

make: *** [test_coap_server] Error 1

I tried to find some info related to error like gnutls. but i couldn't soleve that problem..
if you know how to solve this problem. plz give some commnets for me
Thanks in advance.

Proxy

When I tried to run the test_http_client with the proxy. I noticed that the tests have passed successfully. When I observe the data between the client and proxy using Wireshark, there are no TLS packets between client and proxy but between the proxy and COAP server, there are DTLS packets.

Do I need to do anything to enable TLS on HTTP side?
I have tried the same with tinydtls also but there are no TLS packets between the client and proxy.

I followed the instructions provided in the readme.md to test HTTP/CoAP proxy application with HTTP/TLS/IPv6 and CoAP/DTLS/IPv6

3G or 4G DTLS

Just a quick question. Would it be possible to test FreeCoAP under two raspberry pi boards operating with 3G or 4G connection? thanks

size data frame for DTLS FreeCoAP

Dear all, I have implemented DTLS for CoAP implemented using GnuTLS on two Raspberry Pi. I ran test_client and test_server sample applications with CoAP/DTLS/IPv4 and the certificates were successfully installed. I would like to know the total data frame in bytes for the message that is sent to the serve and its response. Both boards are connected by using a wireless WiFi.
I really appreciate any comment or suggestion. Thank you in advance. Cheers

Using this code with Raspberry Pi

Hello,
How can I upload this code to a Raspberry Pi 3?
I want to use the CoAP server test applications with CoAP/DTLS/IPv6 and using Cupper as a client.

Thanks,

The peer certificate is not trusted

sheraz@sheraz-VirtualBox:~/Desktop/FreeCoAP-master/test/test_proxy_http_coap$ ./proxy
Notice : reading config file: 'proxy.conf'
Notice : config parameter: 'port'='12437'
Notice : config parameter: 'log_level'='debug'
Notice : config parameter: 'key_file'='../../certs/server_privkey.pem'
Notice : config parameter: 'cert_file'='../../certs/server_cert.pem'
Notice : config parameter: 'trust_file'='../../certs/root_client_cert.pem'
Notice : config parameter: 'key_file'='../../certs/client_privkey.pem'
Notice : config parameter: 'cert_file'='../../certs/client_cert.pem'
Notice : config parameter: 'trust_file'='../../certs/root_server_cert.pem'
Notice : finished reading config file: 'proxy.conf'
Notice : Proxy running
Notice : [0] Listening on port 12437
Notice : [0] <0> 127.0.0.1 Connection with HTTP client started
Notice : [0] <0> 127.0.0.1 Transaction with HTTP client started
Error : [0] <0> 127.0.0.1 Failed to read from socket connected to HTTP client: unable to read from socket
Notice : [0] <0> 127.0.0.1 Transaction with HTTP client failed
Notice : [0] <0> 127.0.0.1 Connection with HTTP client failed
Info : OK connections: 0
Info : Failed connections: 1
Info : OK transactions: 0
Info : Failed transactions: 1

./test_http_client 1


test 1: Send GET request
Error : The peer certificate is not trusted
[FAIL]

[Total: 1, Pass: 0, Fail: 1]

How can I solve the bi-directional problem?

When the device is behind NAT/firewall, we should keep the route alive.
How can we do that? How can we solve the bi-directional problem?
The device should be a server and a client, and they should share the same address and port.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.