Skip to content

Commit

Permalink
Fix botattr validation and correct flag usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cizzle committed Sep 30, 2018
1 parent 43b0ce5 commit 3458f51
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions src/flags.c
Expand Up @@ -484,7 +484,7 @@ static int flag2str(char *string, int bot, int udef)
return string - old;
}

static int bot2str(char *string, int bot)
static int bot2str(char *string, unsigned long long bot)
{
char x = 'a', *old = string;

Expand Down Expand Up @@ -703,7 +703,7 @@ void get_user_flagrec(struct userrec *u, struct flag_record *fr,
fr->udef_global = 0;
}
if (fr->match & FR_BOT) {
fr->bot = (long) get_user(&USERENTRY_BOTFL, u);
fr->bot = (unsigned long long) get_user(&USERENTRY_BOTFL, u);
} else
fr->bot = 0;
if (fr->match & FR_CHAN) {
Expand Down Expand Up @@ -775,7 +775,7 @@ static int botfl_write_userfile(FILE *f, struct userrec *u,

static int botfl_set(struct userrec *u, struct user_entry *e, void *buf)
{
long atr = ((long) buf & BOT_VALID);
unsigned long long atr = ((unsigned long long) buf & BOT_VALID);

if (!(u->flags & USER_BOT))
return 1; /* Don't even bother trying to set the
Expand Down
78 changes: 39 additions & 39 deletions src/flags.h
Expand Up @@ -27,7 +27,7 @@ struct flag_record {
int match;
int global;
int udef_global;
intptr_t bot;
unsigned long long bot; /* 36 bits needed */
int chan;
int udef_chan;
};
Expand All @@ -46,7 +46,7 @@ struct flag_record {
* unused letters: is
*
* botflags:
* a?????ghi??l???p?rs??0123456789?????
* a?????ghi??l???p?rs???????0123456789
* unused letters: bcdefjkmnoqtuvwxyz
*
* chanflags:
Expand All @@ -55,7 +55,7 @@ struct flag_record {
*/
#define USER_VALID 0x003fbfeff /* Sum of all valid USER_ flags */
#define CHAN_VALID 0x003637c79 /* Sum of all valid CHAN_ flags */
#define BOT_VALID 0x07fe689C1 /* Sum of all valid BOT_ flags */
#define BOT_VALID 0xffc0689c1ULL /* Sum of all valid BOT_ flags */


#define USER_AUTOOP 0x00000001 /* a auto-op */
Expand Down Expand Up @@ -87,42 +87,42 @@ struct flag_record {
#define USER_DEFAULT 0x40000000 /* use default-flags */

/* Flags specifically for bots */
#define BOT_ALT 0x00000001 /* a auto-link here if all hubs fail */
#define BOT_B 0x00000002 /* b unused */
#define BOT_C 0x00000004 /* c unused */
#define BOT_D 0x00000008 /* d unused */
#define BOT_E 0x00000010 /* e unused */
#define BOT_F 0x00000020 /* f unused */
#define BOT_GLOBAL 0x00000040 /* g all channel are shared */
#define BOT_HUB 0x00000080 /* h auto-link to ONE of these bots */
#define BOT_ISOLATE 0x00000100 /* i isolate party line from botnet */
#define BOT_J 0x00000200 /* j unused */
#define BOT_K 0x00000400 /* k unused */
#define BOT_LEAF 0x00000800 /* l may not link other bots */
#define BOT_M 0x00001000 /* m unused */
#define BOT_N 0x00002000 /* n unused */
#define BOT_O 0x00004000 /* o unused */
#define BOT_PASSIVE 0x00008000 /* p share passively with this bot */
#define BOT_Q 0x00010000 /* q unused */
#define BOT_REJECT 0x00020000 /* r automatically reject anywhere */
#define BOT_AGGRESSIVE 0x00040000 /* s bot shares user files */
#define BOT_T 0x00080000 /* t unused */
#define BOT_U 0x00100000 /* u unused */
#define BOT_V 0x80000000 /* v unused */
#define BOT_W 0x100000000 /* w unused */
#define BOT_X 0x200000000 /* x unused */
#define BOT_Y 0x400000000 /* y unused */
#define BOT_Z 0x800000000 /* z unused */
#define BOT_FLAG0 0x00200000 /* 0 user-defined flag #0 */
#define BOT_FLAG1 0x00400000 /* 1 user-defined flag #1 */
#define BOT_FLAG2 0x00800000 /* 2 user-defined flag #2 */
#define BOT_FLAG3 0x01000000 /* 3 user-defined flag #3 */
#define BOT_FLAG4 0x02000000 /* 4 user-defined flag #4 */
#define BOT_FLAG5 0x04000000 /* 5 user-defined flag #5 */
#define BOT_FLAG6 0x08000000 /* 6 user-defined flag #6 */
#define BOT_FLAG7 0x10000000 /* 7 user-defined flag #7 */
#define BOT_FLAG8 0x20000000 /* 8 user-defined flag #8 */
#define BOT_FLAG9 0x40000000 /* 9 user-defined flag #9 */
#define BOT_ALT 0x00000001ULL /* a auto-link here if all hubs fail */
#define BOT_B 0x00000002ULL /* b unused */
#define BOT_C 0x00000004ULL /* c unused */
#define BOT_D 0x00000008ULL /* d unused */
#define BOT_E 0x00000010ULL /* e unused */
#define BOT_F 0x00000020ULL /* f unused */
#define BOT_GLOBAL 0x00000040ULL /* g all channel are shared */
#define BOT_HUB 0x00000080ULL /* h auto-link to ONE of these bots */
#define BOT_ISOLATE 0x00000100ULL /* i isolate party line from botnet */
#define BOT_J 0x00000200ULL /* j unused */
#define BOT_K 0x00000400ULL /* k unused */
#define BOT_LEAF 0x00000800ULL /* l may not link other bots */
#define BOT_M 0x00001000ULL /* m unused */
#define BOT_N 0x00002000ULL /* n unused */
#define BOT_O 0x00004000ULL /* o unused */
#define BOT_PASSIVE 0x00008000ULL /* p share passively with this bot */
#define BOT_Q 0x00010000ULL /* q unused */
#define BOT_REJECT 0x00020000ULL /* r automatically reject anywhere */
#define BOT_AGGRESSIVE 0x00040000ULL /* s bot shares user files */
#define BOT_T 0x00080000ULL /* t unused */
#define BOT_U 0x00100000ULL /* u unused */
#define BOT_V 0x00200000ULL /* v unused */
#define BOT_W 0x00400000ULL /* w unused */
#define BOT_X 0x00800000ULL /* x unused */
#define BOT_Y 0x01000000ULL /* y unused */
#define BOT_Z 0x02000000ULL /* z unused */
#define BOT_FLAG0 0x04000000ULL /* 0 user-defined flag #0 */
#define BOT_FLAG1 0x08000000ULL /* 1 user-defined flag #1 */
#define BOT_FLAG2 0x10000000ULL /* 2 user-defined flag #2 */
#define BOT_FLAG3 0x20000000ULL /* 3 user-defined flag #3 */
#define BOT_FLAG4 0x40000000ULL /* 4 user-defined flag #4 */
#define BOT_FLAG5 0x80000000ULL /* 5 user-defined flag #5 */
#define BOT_FLAG6 0x100000000ULL /* 6 user-defined flag #6 */
#define BOT_FLAG7 0x200000000ULL /* 7 user-defined flag #7 */
#define BOT_FLAG8 0x400000000ULL /* 8 user-defined flag #8 */
#define BOT_FLAG9 0x800000000ULL /* 9 user-defined flag #9 */
#define BOT_SHARE (BOT_AGGRESSIVE|BOT_PASSIVE)


Expand Down
2 changes: 1 addition & 1 deletion src/users.h
Expand Up @@ -97,7 +97,7 @@ struct user_entry {
char *string;
void *extra;
struct list_type *list;
unsigned long ulong;
unsigned long long ulong;
} u;
char *name;
};
Expand Down

0 comments on commit 3458f51

Please sign in to comment.