int csc_doadduser(void *source, int cargc, char **cargv) {
nick *sender=source;
chanindex *cip;
- regchanuser *rcup;
+ regchanuser *rcup, *rcuplist;
regchan *rcp;
reguser *rup;
flag_t addflags;
char *flagbuf;
-
- int i=1;
+ unsigned int count=0;
+ int i;
if (cargc<2) {
chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "adduser");
flagbuf=printflags(addflags, rcuflags);
- for (;i<cargc;i++) {
+ /* ugh */
+ for (count=i=0;i<REGCHANUSERHASHSIZE;i++)
+ for (rcuplist=rcp->regusers[i];rcuplist;rcuplist=rcuplist->nextbychan)
+ count++;
+
+ for (i=1;i<cargc;i++) {
if (!(rup=findreguser(sender, cargv[i])))
continue;
continue;
}
+ if(count++ >= MAXCHANLEVS) {
+ chanservstdmessage(sender, QM_TOOMANYCHANLEVS);
+ chanservstdmessage(sender, QM_DONE);
+ return CMD_OK;
+ }
+
rcup=getregchanuser();
rcup->chan=rcp;
rcup->user=rup;
}
if (!rcuplist) {
+ /* new user, we could store a count instead... that's probably better... */
+ unsigned int count;
+
+ for (count=i=0;i<REGCHANUSERHASHSIZE;i++)
+ for (rcuplist=rcp->regusers[i];rcuplist;rcuplist=rcuplist->nextbychan)
+ count++;
+
+ if(count >= MAXCHANLEVS) {
+ chanservstdmessage(sender, QM_TOOMANYCHANLEVS);
+ return CMD_ERROR;
+ }
+
rcuplist=getregchanuser();
rcuplist->user=target;
rcuplist->chan=rcp;
reguser *rup=getreguserfromnick(sender);
struct chanban *b;
char banbuf[1024];
+ unsigned int count = 0;
if (cargc<2) {
chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "permban");
b=makeban(banbuf);
for(rbp=rcp->bans;rbp;rbp=rbp->next) {
+ count++;
if(banequal(b,rbp->cbp)) { /* if they're equal and one is temporary we just replace it */
if(rbp->expiry) {
if(toreplace) { /* shouldn't happen */
return CMD_ERROR;
}
+ if(count >= MAXBANS) {
+ freechanban(b);
+ chanservstdmessage(sender, QM_TOOMANYBANS);
+ return CMD_ERROR;
+ }
+
if(toreplace) {
freechanban(b);
chanservstdmessage(sender, QM_REPLACINGTEMPBAN);
unsigned int duration;
struct chanban *b;
char banbuf[1024];
+ unsigned int count = 0;
if (cargc<3) {
chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "tempban");
b=makeban(banbuf);
for(rbp=rcp->bans;rbp;rbp=rbp->next) {
+ count++;
if(banequal(b,rbp->cbp)) {
if(rbp->expiry && (duration > rbp->expiry)) {
if(toreplace) { /* shouldn't happen */
freechanban(b);
return CMD_ERROR;
}
-
+
+ if(count >= MAXBANS) {
+ freechanban(b);
+ chanservstdmessage(sender, QM_TOOMANYBANS);
+ return CMD_ERROR;
+ }
+
if(toreplace) {
freechanban(b);
chanservstdmessage(sender, QM_REPLACINGBANSDURATION);
#define MAXLANG 50
#define MAXMESSAGES 200
+/* Maximum number of user chanlevs and bans */
+#define MAXCHANLEVS 250
+#define MAXBANS 50
+
/* Sources of entropy and standard length defines */
#define ENTROPYSOURCE "/dev/urandom"
#define ENTROPYLEN 8
#define QM_PERMBANALREADYSET 151
#define QM_NOTREPLACINGBANLDURATION 152
#define QM_REPLACINGBANSDURATION 153
+#define QM_TOOMANYCHANLEVS 154
+#define QM_TOOMANYBANS 155
/* List of privileged operations */
/* 151*/ "That permanent ban already exists.",
/* 152*/ "A ban with the same mask and longer duration exists, aborting.",
/* 153*/ "Replacing existing ban with the same mask as it has a shorter duration.",
+ /* 154*/ "Channel has too many user entries, aborting.",
+ /* 155*/ "Channel has too many bans set, aborting.",
};
void initmessages() {