summaryrefslogtreecommitdiff
path: root/ratox.c
diff options
context:
space:
mode:
authorFRIGN <dev@frign.de>2014-10-01 19:50:20 +0200
committersin <sin@2f30.org>2014-10-01 19:06:26 +0100
commit07b2fa713191fd705094f05d4aba21794a012f3f (patch)
treee06240b717a3130d9d02cf1911dc2077f9b721e7 /ratox.c
parent81985bf1d1e46dd6e87a9f73836997154e6c3699 (diff)
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 (limited to 'ratox.c')
-rw-r--r--ratox.c10
1 files changed, 6 insertions, 4 deletions
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);