commit 07b2fa713191fd705094f05d4aba21794a012f3f
parent 81985bf1d1e46dd6e87a9f73836997154e6c3699
Author: FRIGN <dev@frign.de>
Date: Wed, 1 Oct 2014 19:50:20 +0200
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.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git 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);