summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-11-27 20:59:00 +0100
committerCoren[m] <Break@Ocean>2013-11-27 21:00:23 +0100
commit26fef7cf9a5470e5fd24300063be6df3cd9ce723 (patch)
treedd5c70502d755455ecdef289cc11c302c54092ac /toxcore
parent3fe7e087913d07c5805a9e27c267476527de0e84 (diff)
Various changes to nTox including a potential crash (also possible from remote!), and a tiny change to toxcore.
Crash stuff: nTox.c: - do_refresh(): avoid crashes (input a "%" and the client goes "boom!", send someone a string with embedded "%" and see him blow up...) Other stuff: toxcore: tox.h (doc.)/network.c (code): - networking_wait_prepare(): return -1 if lenptr was NULL and therefore not settable nTox.c: - fraddr_to_str(): function to convert a TOX_FRIEND_ADDRESS into a segmented (and therefore line-breakable) string - print_friendlist(): print index of friend on name line, print id on 2nd line - command /f: skip spaces (and +) inside a friend id - command /r (new): "/r #" to remove a friend - main(): reduce cpu consumption if we're not currently sending files
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/network.c9
-rw-r--r--toxcore/tox.h7
2 files changed, 10 insertions, 6 deletions
diff --git a/toxcore/network.c b/toxcore/network.c
index e5a80254..82f29aef 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -310,9 +310,12 @@ typedef struct {
310 310
311int networking_wait_prepare(Networking_Core *net, uint32_t sendqueue_length, uint8_t *data, uint16_t *lenptr) 311int networking_wait_prepare(Networking_Core *net, uint32_t sendqueue_length, uint8_t *data, uint16_t *lenptr)
312{ 312{
313 if ((data == NULL) || (*lenptr < sizeof(select_info))) { 313 if ((data == NULL) || !lenptr || (*lenptr < sizeof(select_info))) {
314 *lenptr = sizeof(select_info); 314 if (lenptr) {
315 return 0; 315 *lenptr = sizeof(select_info);
316 return 0;
317 } else
318 return -1;
316 } 319 }
317 320
318 *lenptr = sizeof(select_info); 321 *lenptr = sizeof(select_info);
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 08727d2a..469a1f78 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -606,10 +606,11 @@ void tox_do(Tox *tox);
606 * Prepares the data required to call tox_wait_execute() asynchronously 606 * Prepares the data required to call tox_wait_execute() asynchronously
607 * 607 *
608 * data[] is reserved and kept by the caller 608 * data[] is reserved and kept by the caller
609 * len is in/out: in = reserved data[], out = required data[] 609 * *lenptr is in/out: in = reserved data[], out = required data[]
610 * 610 *
611 * returns 1 on success 611 * returns 1 on success
612 * returns 0 on failure (length is insufficient) 612 * returns 0 if *lenptr is insufficient
613 * returns -1 if lenptr is NULL
613 * 614 *
614 * 615 *
615 * tox_wait_execute(): function can be called asynchronously 616 * tox_wait_execute(): function can be called asynchronously