cjdelisle/cjdns — Issue #11: null pointer dereference
Author: anarcat
Created: 2012-01-26 04:32:05+00:00
State: open

I downloaded the code from git, and run the following commands on Debian wheezy:

```
1029 cd cjdns/
1030 mkdir build
1031 cd build
1032 cmake ..
1037 make
1041 ./cjdroute --genconf > cjdroute.conf
1042 vim cjdroute.conf
1043 ./cjdroute --getcmds < cjdroute.conf
```

Then as root:

```
root@marcos:/home/anarcat# useradd cjdns
root@marcos:/home/anarcat# /sbin/ip tuntap add mode tun user cjdns
root@marcos:/home/anarcat# /sbin/ip tuntap list | grep `id -u cjdns`
root@marcos:/home/anarcat# /sbin/ip addr add fc37:0d36:ef8d:2707:d8f8:66a8:10e6:259e dev tun0
root@marcos:/home/anarcat# /sbin/ip -6 route add fc00::/8 dev tun0
root@marcos:/home/anarcat# /sbin/ip link set tun0 up
root@marcos:/home/anarcat# cd dist/cjdns/build/
root@marcos:/home/anarcat/dist/cjdns/build# sudo -u cjdns ./cjdroute < cjdroute.conf
Version: $Id: 2f1d86c0677d866378fdbb0105a1ba8d2270e7f3 $
Initializing tun device: tun0
root@marcos:/home/anarcat/dist/cjdns/build#
```

That's a boom, even though it doesn't say so. In a debugger, we clearly see the null pointer dereference:

```
(gdb) run < cjdroute.conf
Starting program: /home/anarcat/dist/cjdns/build/cjdroute < cjdroute.conf
[Thread debugging using libthread_db enabled]
Version: $Id: 2f1d86c0677d866378fdbb0105a1ba8d2270e7f3 $
Initializing tun device: tun0

Program received signal SIGSEGV, Segmentation fault.
0x0000000000417c4d in Admin_registerFunction (name=0x42ad00 "NodeStore_dumpTable",
callback=0x413aa4 , callbackContext=0x638290, admin=0x0)
at /home/anarcat/dist/cjdns/admin/Admin.c:289
289 String* str = String_new(name, admin->allocator);
(gdb) bt
#0 0x0000000000417c4d in Admin_registerFunction (name=0x42ad00 "NodeStore_dumpTable",
callback=0x413aa4 , callbackContext=0x638290, admin=0x0)
at /home/anarcat/dist/cjdns/admin/Admin.c:289
#1 0x000000000041259f in NodeStore_new (myAddress=0x637700, capacity=8192, allocator=0x6304d8,
logger=0x7fffffffe9d0, admin=0x0) at /home/anarcat/dist/cjdns/dht/dhtcore/NodeStore.c:53
#2 0x000000000040eb30 in RouterModule_register (registry=0x6373f0, allocator=0x6304d8,
myAddress=0x7fffffffea30 "ҕq\026\252\246|\002\023\260K\216\203Q\227.\215\355\300\026\277\r\227ֺ\355\372\017Ҍ\200*\340\352\377\377\377\177", eventBase=0x630040, logger=0x7fffffffe9d0, admin=0x0)
at /home/anarcat/dist/cjdns/dht/dhtcore/RouterModule.c:228
#3 0x00000000004067bd in registerRouter (config=0x6312f0,
myPubKey=0x7fffffffea30 "ҕq\026\252\246|\002\023\260K\216\203Q\227.\215\355\300\026\277\r\227ֺ\355\372\017Ҍ\200*\340\352\377\377\377\177", context=0x7fffffffe910)
at /home/anarcat/dist/cjdns/cjdroute.c:529
#4 0x0000000000407048 in main (argc=1, argv=0x7fffffffebf8) at /home/anarcat/dist/cjdns/cjdroute.c:673
```