projects
/
umurmur.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use Client_find_by_session() instead of a few open-coded loops.
[umurmur.git]
/
src
/
ban.c
diff --git
a/src/ban.c
b/src/ban.c
index 47f02edab1c1d3ae3a9e277918499b67b41cb415..84e95dc174e7a3ed881b616a70f4a75d39f573b6 100644
(file)
--- a/
src/ban.c
+++ b/
src/ban.c
@@
-33,6
+33,7
@@
#include <time.h>
#include <string.h>
#include "log.h"
#include <time.h>
#include <string.h>
#include "log.h"
+#include "memory.h"
#include "list.h"
#include "ban.h"
#include "conf.h"
#include "list.h"
#include "ban.h"
#include "conf.h"
@@
-70,9
+71,7
@@
void Ban_UserBan(client_t *client, char *reason)
ban_t *ban;
char hexhash[41];
ban_t *ban;
char hexhash[41];
- ban = calloc(1, sizeof(ban_t));
- if (ban == NULL)
- Log_fatal("Out of memory");
+ ban = Memory_safeCalloc(1, sizeof(ban_t));
memcpy(ban->hash, client->hash, 20);
memcpy(ban->hash, client->hash, 20);
@@
-245,9
+244,7
@@
void Ban_putBanList(message_t *msg, int n_bans)
for (i = 0; i < n_bans; i++) {
Msg_banList_getEntry(msg, i, &address, &mask, &name, &hexhash, &reason, &start, &duration);
for (i = 0; i < n_bans; i++) {
Msg_banList_getEntry(msg, i, &address, &mask, &name, &hexhash, &reason, &start, &duration);
- ban = malloc(sizeof(ban_t));
- if (ban == NULL)
- Log_fatal("Out of memory");
+ ban = Memory_safeMalloc(1, sizeof(ban_t));
SSLi_hex2hash(hexhash, ban->hash);
if(memcmp(address, mappedBytes, 12) == 0) {
SSLi_hex2hash(hexhash, ban->hash);
if(memcmp(address, mappedBytes, 12) == 0) {
@@
-354,10
+351,7
@@
static void Ban_readBanFile(void)
if (p == NULL) break;
reason = p;
if (p == NULL) break;
reason = p;
- ban = malloc(sizeof(ban_t));
- if (ban == NULL)
- Log_fatal("Out of memory");
- memset(ban, 0, sizeof(ban_t));
+ ban = Memory_safeCalloc(1, sizeof(ban_t));
SSLi_hex2hash(hexhash, ban->hash);
if (inet_pton(AF_INET, address, &ban->address) == 0) {
if (inet_pton(AF_INET6, address, &ban->address) == 0) {
SSLi_hex2hash(hexhash, ban->hash);
if (inet_pton(AF_INET, address, &ban->address) == 0) {
if (inet_pton(AF_INET6, address, &ban->address) == 0) {