From 07b2fa713191fd705094f05d4aba21794a012f3f Mon Sep 17 00:00:00 2001 From: FRIGN Date: Wed, 1 Oct 2014 19:50:20 +0200 Subject: Fix a small issue in setnospam and polish the output Previously, it wouldn't check 1-byte-input. Now it does. Also, nospam/out should contain the 8-digit hexadecimal number instead of just the raw string passed to the in-fifo. --- ratox.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ratox.c') diff --git a/ratox.c b/ratox.c index ad19c71..8783f13 100644 --- a/ratox.c +++ b/ratox.c @@ -1345,6 +1345,7 @@ setnospam(void *data) { uint8_t nospam[2 * sizeof(uint32_t) + 1]; uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; + int32_t nsval; ssize_t n, i; n = fiforead(gslots[NOSPAM].dirfd, &gslots[NOSPAM].fd[IN], gfiles[IN], @@ -1355,18 +1356,19 @@ setnospam(void *data) n--; nospam[n] = '\0'; - for (i = 0; i < n - 1; i++) { + for (i = 0; i < n; i++) { if (nospam[i] < '0' || (nospam[i] > '9' && nospam[i] < 'A') || nospam[i] > 'F') { dprintf(gslots[NOSPAM].fd[ERR], "Input contains invalid characters ![0-9, A-F]\n"); goto end; } } - tox_set_nospam(tox, strtol((char *)nospam, NULL, 16)); + nsval = strtol((char *)nospam, NULL, 16); + tox_set_nospam(tox, nsval); datasave(); - printout("Nospam > %s\n", nospam); + printout("Nospam > %08X\n", nsval); ftruncate(gslots[NOSPAM].fd[OUT], 0); - dprintf(gslots[NOSPAM].fd[OUT], "%s\n", nospam); + dprintf(gslots[NOSPAM].fd[OUT], "%08X\n", nsval); tox_get_address(tox, address); ftruncate(idfd, 0); -- cgit v1.2.3