Simplify dynamic memory management.
Add utility routines and use them to simplify the use of dynamically allocated memory. Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
This commit is contained in:
parent
187cf02903
commit
fa014f3a88
@ -47,7 +47,7 @@ HDRS:= bbs.h
|
|||||||
OBJS:= inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o \
|
OBJS:= inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o \
|
||||||
doors.o bbs_list.o chat_system.o email.o files.o settings.o \
|
doors.o bbs_list.o chat_system.o email.o files.o settings.o \
|
||||||
lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o \
|
lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o \
|
||||||
nodelist.o blog.o
|
nodelist.o blog.o util.o
|
||||||
|
|
||||||
WWWOBJS:= ../deps/aha/aha.o ../deps/hashids/hashids.o www.o www_email.o \
|
WWWOBJS:= ../deps/aha/aha.o ../deps/hashids/hashids.o www.o www_email.o \
|
||||||
www_msgs.o www_last10.o www_blog.o www_files.o ${OBJS}
|
www_msgs.o www_last10.o www_blog.o www_files.o ${OBJS}
|
||||||
|
14
src/bbs.c
14
src/bbs.c
@ -120,7 +120,7 @@ struct fido_addr *parse_fido_addr(const char *str) {
|
|||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
struct fido_addr *ret = (struct fido_addr *)malloc(sizeof(struct fido_addr));
|
struct fido_addr *ret = (struct fido_addr *)malloz(sizeof(struct fido_addr));
|
||||||
int c;
|
int c;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
||||||
@ -246,9 +246,8 @@ void s_putchar(char c) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ic = iconv_open("UTF-8", "CP437");
|
ic = iconv_open("UTF-8", "CP437");
|
||||||
inbuf = (char *)malloc(4);
|
inbuf = (char *)malloz(4);
|
||||||
outbuf = (char *)malloc(4);
|
outbuf = (char *)malloz(4);
|
||||||
memset(outbuf, 0, 4);
|
|
||||||
sprintf(inbuf, "%c", c);
|
sprintf(inbuf, "%c", c);
|
||||||
inc = 1;
|
inc = 1;
|
||||||
ouc = 4;
|
ouc = 4;
|
||||||
@ -296,8 +295,7 @@ void s_putstring(char *c) {
|
|||||||
ic = iconv_open("UTF-8", "CP437");
|
ic = iconv_open("UTF-8", "CP437");
|
||||||
inc = strlen(c);
|
inc = strlen(c);
|
||||||
inbuf = strdup(c);
|
inbuf = strdup(c);
|
||||||
outbuf = (char *)malloc(inc * 4);
|
outbuf = (char *)malloz(inc * 4);
|
||||||
memset(outbuf, 0, inc * 4);
|
|
||||||
ptr1 = outbuf;
|
ptr1 = outbuf;
|
||||||
ptr2 = inbuf;
|
ptr2 = inbuf;
|
||||||
ouc = inc * 4;
|
ouc = inc * 4;
|
||||||
@ -1341,7 +1339,7 @@ char *str_replace(const char *str, const char *from, const char *to) {
|
|||||||
retlen = orglen + (tolen - fromlen) * count;
|
retlen = orglen + (tolen - fromlen) * count;
|
||||||
} else
|
} else
|
||||||
retlen = orglen;
|
retlen = orglen;
|
||||||
ret = malloc(retlen + 1);
|
ret = malloz(retlen + 1);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
goto end_repl_str;
|
goto end_repl_str;
|
||||||
}
|
}
|
||||||
@ -1371,4 +1369,4 @@ end_repl_str:
|
|||||||
* which will be NULL in the event of an error. */
|
* which will be NULL in the event of an error. */
|
||||||
free(pos_cache);
|
free(pos_cache);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -373,6 +373,14 @@ extern void load_strings();
|
|||||||
extern char *get_string(int offset);
|
extern char *get_string(int offset);
|
||||||
extern void chomp(char *string);
|
extern void chomp(char *string);
|
||||||
|
|
||||||
|
extern void die(const char *msg);
|
||||||
|
extern void *malloz(size_t size);
|
||||||
|
extern char *file2str(const char *path);
|
||||||
|
extern char *str5dup(const char *a, const char *b, const char *c, const char *d, const char *e);
|
||||||
|
extern char *str4dup(const char *a, const char *b, const char *c, const char *d);
|
||||||
|
extern char *str3dup(const char *a, const char *b, const char *c);
|
||||||
|
extern char *str2dup(const char *a, const char *b);
|
||||||
|
|
||||||
#if defined(ENABLE_WWW)
|
#if defined(ENABLE_WWW)
|
||||||
extern void www_init();
|
extern void www_init();
|
||||||
extern void *www_logger(void *cls, const char *uri, struct MHD_Connection *con);
|
extern void *www_logger(void *cls, const char *uri, struct MHD_Connection *con);
|
||||||
|
@ -212,11 +212,11 @@ void bbs_list() {
|
|||||||
} else {
|
} else {
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (entrycount == 0) {
|
if (entrycount == 0) {
|
||||||
entries = (struct bbs_list_entry_t **)malloc(sizeof(struct bbs_list_entry_t *));
|
entries = (struct bbs_list_entry_t **)malloz(sizeof(struct bbs_list_entry_t *));
|
||||||
} else {
|
} else {
|
||||||
entries = (struct bbs_list_entry_t **)realloc(entries, sizeof(struct bbs_list_entry_t *) * (entrycount + 1));
|
entries = (struct bbs_list_entry_t **)realloc(entries, sizeof(struct bbs_list_entry_t *) * (entrycount + 1));
|
||||||
}
|
}
|
||||||
entries[entrycount] = (struct bbs_list_entry_t *)malloc(sizeof(struct bbs_list_entry_t));
|
entries[entrycount] = (struct bbs_list_entry_t *)malloz(sizeof(struct bbs_list_entry_t));
|
||||||
|
|
||||||
entries[entrycount]->id = sqlite3_column_int(res, 0);
|
entries[entrycount]->id = sqlite3_column_int(res, 0);
|
||||||
entries[entrycount]->bbsname = strdup(sqlite3_column_text(res, 1));
|
entries[entrycount]->bbsname = strdup(sqlite3_column_text(res, 1));
|
||||||
@ -255,7 +255,7 @@ void bbs_list() {
|
|||||||
free(entries);
|
free(entries);
|
||||||
return;
|
return;
|
||||||
} else if (tolower(c) == 'a') {
|
} else if (tolower(c) == 'a') {
|
||||||
newentry = (struct bbs_list_entry_t *)malloc(sizeof(struct bbs_list_entry_t));
|
newentry = (struct bbs_list_entry_t *)malloz(sizeof(struct bbs_list_entry_t));
|
||||||
if (add_bbs(newentry)) {
|
if (add_bbs(newentry)) {
|
||||||
entries = (struct bbs_list_entry_t **)realloc(entries, sizeof(struct bbs_list_entry_t *) * (entrycount + 1));
|
entries = (struct bbs_list_entry_t **)realloc(entries, sizeof(struct bbs_list_entry_t *) * (entrycount + 1));
|
||||||
entries[entrycount] = newentry;
|
entries[entrycount] = newentry;
|
||||||
|
@ -36,11 +36,11 @@ int blog_load(struct blog_entry_t ***entries) {
|
|||||||
}
|
}
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (blog_entry_count == 0) {
|
if (blog_entry_count == 0) {
|
||||||
blog_entries = (struct blog_entry_t **)malloc(sizeof(struct blog_entry_t *));
|
blog_entries = (struct blog_entry_t **)malloz(sizeof(struct blog_entry_t *));
|
||||||
} else {
|
} else {
|
||||||
blog_entries = (struct blog_entry_t **)realloc(blog_entries, sizeof(struct blog_entry_t *) * (blog_entry_count + 1));
|
blog_entries = (struct blog_entry_t **)realloc(blog_entries, sizeof(struct blog_entry_t *) * (blog_entry_count + 1));
|
||||||
}
|
}
|
||||||
blog_entries[blog_entry_count] = (struct blog_entry_t *)malloc(sizeof(struct blog_entry_t));
|
blog_entries[blog_entry_count] = (struct blog_entry_t *)malloz(sizeof(struct blog_entry_t));
|
||||||
|
|
||||||
blog_entries[blog_entry_count]->author = strdup(sqlite3_column_text(res, 0));
|
blog_entries[blog_entry_count]->author = strdup(sqlite3_column_text(res, 0));
|
||||||
blog_entries[blog_entry_count]->subject = strdup(sqlite3_column_text(res, 1));
|
blog_entries[blog_entry_count]->subject = strdup(sqlite3_column_text(res, 1));
|
||||||
@ -252,4 +252,4 @@ void blog_write() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free(blog_subject);
|
free(blog_subject);
|
||||||
}
|
}
|
||||||
|
@ -253,8 +253,8 @@ int bwave_scan_area(int confr, int area, int areano, int totmsgs, FILE *fti_file
|
|||||||
fti.orig_node = 0;
|
fti.orig_node = 0;
|
||||||
}
|
}
|
||||||
// write msg data
|
// write msg data
|
||||||
body = (char *)malloc(msghs->msgs[k]->msg_h->TxtLen);
|
body = (char *)malloz(msghs->msgs[k]->msg_h->TxtLen);
|
||||||
JAM_ReadMsgText(jb, msghs->msgs[k]->msg_h->TxtOffset, msghs->msgs[k]->msg_h->TxtLen, (char *)body);
|
JAM_ReadMsgText(jb, msghs->msgs[k]->msg_h->TxtOffset, msghs->msgs[k]->msg_h->TxtLen, body);
|
||||||
|
|
||||||
fwrite(body, 1, msghs->msgs[k]->msg_h->TxtLen, dat_file);
|
fwrite(body, 1, msghs->msgs[k]->msg_h->TxtLen, dat_file);
|
||||||
fwrite(&fti, sizeof(FTI_REC), 1, fti_file);
|
fwrite(&fti, sizeof(FTI_REC), 1, fti_file);
|
||||||
@ -303,9 +303,9 @@ void bwave_create_packet() {
|
|||||||
int stin;
|
int stin;
|
||||||
int sterr;
|
int sterr;
|
||||||
char *weekday[] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
|
char *weekday[] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
|
||||||
|
struct stat s;
|
||||||
struct termios oldit;
|
struct termios oldit;
|
||||||
struct termios oldot;
|
struct termios oldot;
|
||||||
struct stat s;
|
|
||||||
struct tm time_tm;
|
struct tm time_tm;
|
||||||
time_t thetime;
|
time_t thetime;
|
||||||
FILE *mix_file;
|
FILE *mix_file;
|
||||||
@ -386,12 +386,10 @@ void bwave_create_packet() {
|
|||||||
|
|
||||||
totmsgs = bwave_scan_email(area_count + 1, totmsgs, fti_file, mix_file, dat_file, &last_ptr);
|
totmsgs = bwave_scan_email(area_count + 1, totmsgs, fti_file, mix_file, dat_file, &last_ptr);
|
||||||
s_printf(get_string(195), "Private Email", "Private Email", totmsgs);
|
s_printf(get_string(195), "Private Email", "Private Email", totmsgs);
|
||||||
areas = (INF_AREA_INFO **)malloc(sizeof(INF_AREA_INFO *));
|
areas = (INF_AREA_INFO **)malloz(sizeof(INF_AREA_INFO *));
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
areas[area_count] = (INF_AREA_INFO *)malloc(sizeof(INF_AREA_INFO));
|
areas[area_count] = (INF_AREA_INFO *)malloz(sizeof(INF_AREA_INFO));
|
||||||
|
|
||||||
memset(areas[area_count], 0, sizeof(INF_AREA_INFO));
|
|
||||||
|
|
||||||
snprintf(areas[area_count]->areanum, 6, "%d", area_count + 1);
|
snprintf(areas[area_count]->areanum, 6, "%d", area_count + 1);
|
||||||
|
|
||||||
@ -422,9 +420,7 @@ void bwave_create_packet() {
|
|||||||
areas = (INF_AREA_INFO **)realloc(areas, sizeof(INF_AREA_INFO *) * (area_count + 1));
|
areas = (INF_AREA_INFO **)realloc(areas, sizeof(INF_AREA_INFO *) * (area_count + 1));
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
areas[area_count] = (INF_AREA_INFO *)malloc(sizeof(INF_AREA_INFO));
|
areas[area_count] = (INF_AREA_INFO *)malloz(sizeof(INF_AREA_INFO));
|
||||||
|
|
||||||
memset(areas[area_count], 0, sizeof(INF_AREA_INFO));
|
|
||||||
|
|
||||||
snprintf(areas[area_count]->areanum, 6, "%d", area_count + 1);
|
snprintf(areas[area_count]->areanum, 6, "%d", area_count + 1);
|
||||||
|
|
||||||
@ -534,7 +530,7 @@ void bwave_create_packet() {
|
|||||||
dup2(bbs_stdin, STDIN_FILENO);
|
dup2(bbs_stdin, STDIN_FILENO);
|
||||||
}
|
}
|
||||||
|
|
||||||
args = (char **)malloc(sizeof(char *));
|
args = (char **)malloz(sizeof(char *));
|
||||||
arg_count = 0;
|
arg_count = 0;
|
||||||
args[arg_count] = strtok(buffer, " ");
|
args[arg_count] = strtok(buffer, " ");
|
||||||
while (args[arg_count] != NULL) {
|
while (args[arg_count] != NULL) {
|
||||||
@ -793,8 +789,8 @@ void bwave_upload_reply() {
|
|||||||
tWORD msg_attr;
|
tWORD msg_attr;
|
||||||
struct fido_addr addr;
|
struct fido_addr addr;
|
||||||
char *body;
|
char *body;
|
||||||
struct stat s;
|
|
||||||
char *tagline;
|
char *tagline;
|
||||||
|
struct stat s;
|
||||||
int echomail = 0;
|
int echomail = 0;
|
||||||
int netmail = 0;
|
int netmail = 0;
|
||||||
FILE *upl_file;
|
FILE *upl_file;
|
||||||
@ -871,7 +867,7 @@ void bwave_upload_reply() {
|
|||||||
dup2(bbs_stderr, STDERR_FILENO);
|
dup2(bbs_stderr, STDERR_FILENO);
|
||||||
dup2(bbs_stdin, STDIN_FILENO);
|
dup2(bbs_stdin, STDIN_FILENO);
|
||||||
}
|
}
|
||||||
args = (char **)malloc(sizeof(char *));
|
args = (char **)malloz(sizeof(char *));
|
||||||
arg_count = 0;
|
arg_count = 0;
|
||||||
args[arg_count] = strtok(buffer, " ");
|
args[arg_count] = strtok(buffer, " ");
|
||||||
while (args[arg_count] != NULL) {
|
while (args[arg_count] != NULL) {
|
||||||
@ -934,22 +930,11 @@ void bwave_upload_reply() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(msgbuffer, 1024, "%s/node%d/bwave/%s", conf.bbs_path, mynode, upl_rec.filename);
|
snprintf(msgbuffer, 1024, "%s/node%d/bwave/%s", conf.bbs_path, mynode, upl_rec.filename);
|
||||||
if (stat(msgbuffer, &s) != 0) {
|
body = file2str(msgbuffer);
|
||||||
|
if (body == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
body = (char *)malloc(s.st_size + 1);
|
|
||||||
msg_file = fopen(msgbuffer, "r");
|
|
||||||
if (!msg_file) {
|
|
||||||
free(body);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
fread(body, 1, s.st_size, msg_file);
|
|
||||||
fclose(msg_file);
|
|
||||||
|
|
||||||
body[s.st_size] = '\0';
|
|
||||||
|
|
||||||
bpos = 0;
|
bpos = 0;
|
||||||
for (i = 0; i < strlen(body); i++) {
|
for (i = 0; i < strlen(body); i++) {
|
||||||
if (body[i] != '\n') {
|
if (body[i] != '\n') {
|
||||||
@ -1087,20 +1072,10 @@ void bwave_upload_reply() {
|
|||||||
snprintf(originlinebuffer, 256, "\r");
|
snprintf(originlinebuffer, 256, "\r");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(msgbuffer, &s) != 0) {
|
body = file2str(msgbuffer);
|
||||||
|
if (body == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
body = (char *)malloc(s.st_size + 1 + strlen(originlinebuffer));
|
|
||||||
msg_file = fopen(msgbuffer, "r");
|
|
||||||
if (!msg_file) {
|
|
||||||
free(body);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
fread(body, 1, s.st_size, msg_file);
|
|
||||||
fclose(msg_file);
|
|
||||||
|
|
||||||
body[s.st_size] = '\0';
|
|
||||||
|
|
||||||
strcat(body, originlinebuffer);
|
strcat(body, originlinebuffer);
|
||||||
|
|
||||||
|
@ -352,11 +352,11 @@ void chat_system(struct user_record *user) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
screenbuffer = (struct character_t ***)malloc(sizeof(struct character_t **) * 23);
|
screenbuffer = (struct character_t ***)malloz(sizeof(struct character_t **) * 23);
|
||||||
for (i = 0; i < 23; i++) {
|
for (i = 0; i < 23; i++) {
|
||||||
screenbuffer[i] = (struct character_t **)malloc(sizeof(struct character_t *) * 80);
|
screenbuffer[i] = (struct character_t **)malloz(sizeof(struct character_t *) * 80);
|
||||||
for (z = 0; z < 80; z++) {
|
for (z = 0; z < 80; z++) {
|
||||||
screenbuffer[i][z] = (struct character_t *)malloc(sizeof(struct character_t));
|
screenbuffer[i][z] = (struct character_t *)malloz(sizeof(struct character_t));
|
||||||
screenbuffer[i][z]->c = '\0';
|
screenbuffer[i][z]->c = '\0';
|
||||||
screenbuffer[i][z]->color = 7;
|
screenbuffer[i][z]->color = 7;
|
||||||
}
|
}
|
||||||
|
@ -421,9 +421,8 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
|||||||
ic = iconv_open(codepage, "UTF-8");
|
ic = iconv_open(codepage, "UTF-8");
|
||||||
}
|
}
|
||||||
ptr1 = outbuf;
|
ptr1 = outbuf;
|
||||||
ptr2 = (char *)malloc((g + 1) * 4);
|
ptr2 = (char *)malloz((g + 1) * 4);
|
||||||
ptr2p = ptr2;
|
ptr2p = ptr2;
|
||||||
memset(ptr2, 0, (g + 1) * 4);
|
|
||||||
inc = g;
|
inc = g;
|
||||||
ouc = (g + 1) * 4;
|
ouc = (g + 1) * 4;
|
||||||
|
|
||||||
@ -456,9 +455,8 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
|||||||
ic = iconv_open("UTF-8", codepage);
|
ic = iconv_open("UTF-8", codepage);
|
||||||
}
|
}
|
||||||
ptr1 = outbuf;
|
ptr1 = outbuf;
|
||||||
ptr2 = (char *)malloc((g + 1) * 4);
|
ptr2 = (char *)malloz((g + 1) * 4);
|
||||||
ptr2p = ptr2;
|
ptr2p = ptr2;
|
||||||
memset(ptr2, 0, (g + 1) * 4);
|
|
||||||
inc = g;
|
inc = g;
|
||||||
ouc = (g + 1) * 4;
|
ouc = (g + 1) * 4;
|
||||||
|
|
||||||
@ -525,7 +523,7 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
|||||||
if (cwd != NULL) {
|
if (cwd != NULL) {
|
||||||
chdir(cwd);
|
chdir(cwd);
|
||||||
}
|
}
|
||||||
args = (char **)malloc(sizeof(char *));
|
args = (char **)malloz(sizeof(char *));
|
||||||
arg_count = 0;
|
arg_count = 0;
|
||||||
args[arg_count] = strtok(buffer, " ");
|
args[arg_count] = strtok(buffer, " ");
|
||||||
while (args[arg_count] != NULL) {
|
while (args[arg_count] != NULL) {
|
||||||
|
11
src/email.c
11
src/email.c
@ -162,12 +162,12 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema
|
|||||||
for (z = 0; z < strlen(emails[msgno]->body); z++) {
|
for (z = 0; z < strlen(emails[msgno]->body); z++) {
|
||||||
if (emails[msgno]->body[z] == '\r' || chars == 79) {
|
if (emails[msgno]->body[z] == '\r' || chars == 79) {
|
||||||
if (msg_line_count == 0) {
|
if (msg_line_count == 0) {
|
||||||
msg_lines = (char **)malloc(sizeof(char *));
|
msg_lines = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
msg_lines = (char **)realloc(msg_lines, sizeof(char *) * (msg_line_count + 1));
|
msg_lines = (char **)realloc(msg_lines, sizeof(char *) * (msg_line_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_lines[msg_line_count] = (char *)malloc(sizeof(char) * (z - start_line + 1));
|
msg_lines[msg_line_count] = (char *)malloz(sizeof(char) * (z - start_line + 1));
|
||||||
|
|
||||||
if (z == start_line) {
|
if (z == start_line) {
|
||||||
msg_lines[msg_line_count][0] = '\0';
|
msg_lines[msg_line_count][0] = '\0';
|
||||||
@ -278,8 +278,7 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema
|
|||||||
snprintf(buffer, 256, "%s", emails[msgno]->subject);
|
snprintf(buffer, 256, "%s", emails[msgno]->subject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subject = (char *)malloc(strlen(buffer) + 1);
|
subject = strdup(buffer);
|
||||||
strcpy(subject, buffer);
|
|
||||||
|
|
||||||
replybody = external_editor(user, user->loginname, emails[msgno]->from, emails[msgno]->body, strlen(emails[msgno]->body), emails[msgno]->from, subject, 1, 0);
|
replybody = external_editor(user, user->loginname, emails[msgno]->from, emails[msgno]->body, strlen(emails[msgno]->body), emails[msgno]->from, subject, 1, 0);
|
||||||
if (replybody != NULL) {
|
if (replybody != NULL) {
|
||||||
@ -399,12 +398,12 @@ void list_emails(struct user_record *user) {
|
|||||||
email_count = 0;
|
email_count = 0;
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (email_count == 0) {
|
if (email_count == 0) {
|
||||||
emails = (struct email_msg **)malloc(sizeof(struct email_msg *));
|
emails = (struct email_msg **)malloz(sizeof(struct email_msg *));
|
||||||
} else {
|
} else {
|
||||||
emails = (struct email_msg **)realloc(emails, sizeof(struct email_msg *) * (email_count + 1));
|
emails = (struct email_msg **)realloc(emails, sizeof(struct email_msg *) * (email_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
emails[email_count] = (struct email_msg *)malloc(sizeof(struct email_msg));
|
emails[email_count] = (struct email_msg *)malloz(sizeof(struct email_msg));
|
||||||
|
|
||||||
emails[email_count]->from = strdup((char *)sqlite3_column_text(res, 0));
|
emails[email_count]->from = strdup((char *)sqlite3_column_text(res, 0));
|
||||||
emails[email_count]->subject = strdup((char *)sqlite3_column_text(res, 1));
|
emails[email_count]->subject = strdup((char *)sqlite3_column_text(res, 1));
|
||||||
|
56
src/files.c
56
src/files.c
@ -370,7 +370,7 @@ char *get_file_id_diz(char *filename) {
|
|||||||
dup2(bbs_stderr, STDERR_FILENO);
|
dup2(bbs_stderr, STDERR_FILENO);
|
||||||
dup2(bbs_stdin, STDIN_FILENO);
|
dup2(bbs_stdin, STDIN_FILENO);
|
||||||
}
|
}
|
||||||
args = (char **)malloc(sizeof(char *));
|
args = (char **)malloz(sizeof(char *));
|
||||||
arg_count = 0;
|
arg_count = 0;
|
||||||
args[arg_count] = strtok(buffer, " ");
|
args[arg_count] = strtok(buffer, " ");
|
||||||
while (args[arg_count] != NULL) {
|
while (args[arg_count] != NULL) {
|
||||||
@ -403,23 +403,17 @@ char *get_file_id_diz(char *filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buffer, 1024, "%s/node%d/temp/FILE_ID.DIZ", conf.bbs_path, mynode);
|
snprintf(buffer, 1024, "%s/node%d/temp/FILE_ID.DIZ", conf.bbs_path, mynode);
|
||||||
if (stat(buffer, &s) != 0) {
|
description = file2str(buffer);
|
||||||
|
if (description == NULL) {
|
||||||
snprintf(buffer, 1024, "%s/node%d/temp/file_id.diz", conf.bbs_path, mynode);
|
snprintf(buffer, 1024, "%s/node%d/temp/file_id.diz", conf.bbs_path, mynode);
|
||||||
if (stat(buffer, &s) != 0) {
|
description = file2str(buffer);
|
||||||
|
if (description == NULL) {
|
||||||
snprintf(buffer, 1024, "%s/node%d/temp", conf.bbs_path, mynode);
|
snprintf(buffer, 1024, "%s/node%d/temp", conf.bbs_path, mynode);
|
||||||
recursive_delete(buffer);
|
recursive_delete(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
description = (char *)malloc(s.st_size + 1);
|
|
||||||
|
|
||||||
fptr = fopen(buffer, "rb");
|
|
||||||
|
|
||||||
fread(description, 1, s.st_size, fptr);
|
|
||||||
description[s.st_size] = '\0';
|
|
||||||
fclose(fptr);
|
|
||||||
|
|
||||||
bpos = 0;
|
bpos = 0;
|
||||||
len = strlen(description);
|
len = strlen(description);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
@ -510,7 +504,7 @@ int do_download(struct user_record *user, char *file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bpos = 1;
|
bpos = 1;
|
||||||
arguments = (char **)malloc(sizeof(char *) * (argc + 1));
|
arguments = (char **)malloz(sizeof(char *) * (argc + 1));
|
||||||
len = strlen(download_command);
|
len = strlen(download_command);
|
||||||
for (i = 0; i < len;) {
|
for (i = 0; i < len;) {
|
||||||
if (download_command[i] != ' ') {
|
if (download_command[i] != ' ') {
|
||||||
@ -618,7 +612,7 @@ int do_upload(struct user_record *user, char *final_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bpos = 1;
|
bpos = 1;
|
||||||
arguments = (char **)malloc(sizeof(char *) * (argc + 1));
|
arguments = (char **)malloz(sizeof(char *) * (argc + 1));
|
||||||
len = strlen(upload_command);
|
len = strlen(upload_command);
|
||||||
for (i = 0; i < len;) {
|
for (i = 0; i < len;) {
|
||||||
if (upload_command[i] != ' ') {
|
if (upload_command[i] != ' ') {
|
||||||
@ -1073,11 +1067,11 @@ void do_list_files(struct file_entry **files_e, int files_c) {
|
|||||||
}
|
}
|
||||||
if (match == 0) {
|
if (match == 0) {
|
||||||
if (tagged_count == 0) {
|
if (tagged_count == 0) {
|
||||||
tagged_files = (struct tagged_file **)malloc(sizeof(struct tagged_file *));
|
tagged_files = (struct tagged_file **)malloz(sizeof(struct tagged_file *));
|
||||||
} else {
|
} else {
|
||||||
tagged_files = (struct tagged_file **)realloc(tagged_files, sizeof(struct tagged_file *) * (tagged_count + 1));
|
tagged_files = (struct tagged_file **)realloc(tagged_files, sizeof(struct tagged_file *) * (tagged_count + 1));
|
||||||
}
|
}
|
||||||
tagged_files[tagged_count] = (struct tagged_file *)malloc(sizeof(struct tagged_file));
|
tagged_files[tagged_count] = (struct tagged_file *)malloz(sizeof(struct tagged_file));
|
||||||
tagged_files[tagged_count]->filename = strdup(files_e[z]->filename);
|
tagged_files[tagged_count]->filename = strdup(files_e[z]->filename);
|
||||||
tagged_files[tagged_count]->dir = files_e[z]->dir;
|
tagged_files[tagged_count]->dir = files_e[z]->dir;
|
||||||
tagged_files[tagged_count]->sub = files_e[z]->sub;
|
tagged_files[tagged_count]->sub = files_e[z]->sub;
|
||||||
@ -1131,11 +1125,11 @@ void do_list_files(struct file_entry **files_e, int files_c) {
|
|||||||
}
|
}
|
||||||
if (match == 0) {
|
if (match == 0) {
|
||||||
if (tagged_count == 0) {
|
if (tagged_count == 0) {
|
||||||
tagged_files = (struct tagged_file **)malloc(sizeof(struct tagged_file *));
|
tagged_files = (struct tagged_file **)malloz(sizeof(struct tagged_file *));
|
||||||
} else {
|
} else {
|
||||||
tagged_files = (struct tagged_file **)realloc(tagged_files, sizeof(struct tagged_file *) * (tagged_count + 1));
|
tagged_files = (struct tagged_file **)realloc(tagged_files, sizeof(struct tagged_file *) * (tagged_count + 1));
|
||||||
}
|
}
|
||||||
tagged_files[tagged_count] = (struct tagged_file *)malloc(sizeof(struct tagged_file));
|
tagged_files[tagged_count] = (struct tagged_file *)malloz(sizeof(struct tagged_file));
|
||||||
tagged_files[tagged_count]->filename = strdup(files_e[z]->filename);
|
tagged_files[tagged_count]->filename = strdup(files_e[z]->filename);
|
||||||
tagged_files[tagged_count]->dir = files_e[z]->dir;
|
tagged_files[tagged_count]->dir = files_e[z]->dir;
|
||||||
tagged_files[tagged_count]->sub = files_e[z]->sub;
|
tagged_files[tagged_count]->sub = files_e[z]->sub;
|
||||||
@ -1178,11 +1172,11 @@ void do_list_files(struct file_entry **files_e, int files_c) {
|
|||||||
}
|
}
|
||||||
if (match == 0) {
|
if (match == 0) {
|
||||||
if (tagged_count == 0) {
|
if (tagged_count == 0) {
|
||||||
tagged_files = (struct tagged_file **)malloc(sizeof(struct tagged_file *));
|
tagged_files = (struct tagged_file **)malloz(sizeof(struct tagged_file *));
|
||||||
} else {
|
} else {
|
||||||
tagged_files = (struct tagged_file **)realloc(tagged_files, sizeof(struct tagged_file *) * (tagged_count + 1));
|
tagged_files = (struct tagged_file **)realloc(tagged_files, sizeof(struct tagged_file *) * (tagged_count + 1));
|
||||||
}
|
}
|
||||||
tagged_files[tagged_count] = (struct tagged_file *)malloc(sizeof(struct tagged_file));
|
tagged_files[tagged_count] = (struct tagged_file *)malloz(sizeof(struct tagged_file));
|
||||||
tagged_files[tagged_count]->filename = strdup(files_e[z]->filename);
|
tagged_files[tagged_count]->filename = strdup(files_e[z]->filename);
|
||||||
tagged_files[tagged_count]->dir = files_e[z]->dir;
|
tagged_files[tagged_count]->dir = files_e[z]->dir;
|
||||||
tagged_files[tagged_count]->sub = files_e[z]->sub;
|
tagged_files[tagged_count]->sub = files_e[z]->sub;
|
||||||
@ -1249,12 +1243,12 @@ void file_search() {
|
|||||||
ptr = strtok(buffer, " ");
|
ptr = strtok(buffer, " ");
|
||||||
while (ptr != NULL) {
|
while (ptr != NULL) {
|
||||||
if (searchterm_count == 0) {
|
if (searchterm_count == 0) {
|
||||||
searchterms = (char **)malloc(sizeof(char *));
|
searchterms = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
searchterms = (char **)realloc(searchterms, sizeof(char *) * (searchterm_count + 1));
|
searchterms = (char **)realloc(searchterms, sizeof(char *) * (searchterm_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchterms[searchterm_count] = malloc(strlen(ptr) + 3);
|
searchterms[searchterm_count] = malloz(strlen(ptr) + 3);
|
||||||
sprintf(searchterms[searchterm_count], "%%%s%%", ptr);
|
sprintf(searchterms[searchterm_count], "%%%s%%", ptr);
|
||||||
searchterm_count++;
|
searchterm_count++;
|
||||||
ptr = strtok(NULL, " ");
|
ptr = strtok(NULL, " ");
|
||||||
@ -1322,11 +1316,11 @@ void file_search() {
|
|||||||
|
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (files_c == 0) {
|
if (files_c == 0) {
|
||||||
files_e = (struct file_entry **)malloc(sizeof(struct file_entry *));
|
files_e = (struct file_entry **)malloz(sizeof(struct file_entry *));
|
||||||
} else {
|
} else {
|
||||||
files_e = (struct file_entry **)realloc(files_e, sizeof(struct file_entry *) * (files_c + 1));
|
files_e = (struct file_entry **)realloc(files_e, sizeof(struct file_entry *) * (files_c + 1));
|
||||||
}
|
}
|
||||||
files_e[files_c] = (struct file_entry *)malloc(sizeof(struct file_entry));
|
files_e[files_c] = (struct file_entry *)malloz(sizeof(struct file_entry));
|
||||||
files_e[files_c]->fid = sqlite3_column_int(res, 0);
|
files_e[files_c]->fid = sqlite3_column_int(res, 0);
|
||||||
files_e[files_c]->filename = strdup((char *)sqlite3_column_text(res, 1));
|
files_e[files_c]->filename = strdup((char *)sqlite3_column_text(res, 1));
|
||||||
files_e[files_c]->description = strdup((char *)sqlite3_column_text(res, 2));
|
files_e[files_c]->description = strdup((char *)sqlite3_column_text(res, 2));
|
||||||
@ -1384,11 +1378,11 @@ void file_search() {
|
|||||||
|
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (files_c == 0) {
|
if (files_c == 0) {
|
||||||
files_e = (struct file_entry **)malloc(sizeof(struct file_entry *));
|
files_e = (struct file_entry **)malloz(sizeof(struct file_entry *));
|
||||||
} else {
|
} else {
|
||||||
files_e = (struct file_entry **)realloc(files_e, sizeof(struct file_entry *) * (files_c + 1));
|
files_e = (struct file_entry **)realloc(files_e, sizeof(struct file_entry *) * (files_c + 1));
|
||||||
}
|
}
|
||||||
files_e[files_c] = (struct file_entry *)malloc(sizeof(struct file_entry));
|
files_e[files_c] = (struct file_entry *)malloz(sizeof(struct file_entry));
|
||||||
files_e[files_c]->fid = sqlite3_column_int(res, 0);
|
files_e[files_c]->fid = sqlite3_column_int(res, 0);
|
||||||
files_e[files_c]->filename = strdup((char *)sqlite3_column_text(res, 1));
|
files_e[files_c]->filename = strdup((char *)sqlite3_column_text(res, 1));
|
||||||
files_e[files_c]->description = strdup((char *)sqlite3_column_text(res, 2));
|
files_e[files_c]->description = strdup((char *)sqlite3_column_text(res, 2));
|
||||||
@ -1471,11 +1465,11 @@ void list_files(struct user_record *user) {
|
|||||||
|
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (files_c == 0) {
|
if (files_c == 0) {
|
||||||
files_e = (struct file_entry **)malloc(sizeof(struct file_entry *));
|
files_e = (struct file_entry **)malloz(sizeof(struct file_entry *));
|
||||||
} else {
|
} else {
|
||||||
files_e = (struct file_entry **)realloc(files_e, sizeof(struct file_entry *) * (files_c + 1));
|
files_e = (struct file_entry **)realloc(files_e, sizeof(struct file_entry *) * (files_c + 1));
|
||||||
}
|
}
|
||||||
files_e[files_c] = (struct file_entry *)malloc(sizeof(struct file_entry));
|
files_e[files_c] = (struct file_entry *)malloz(sizeof(struct file_entry));
|
||||||
files_e[files_c]->fid = sqlite3_column_int(res, 0);
|
files_e[files_c]->fid = sqlite3_column_int(res, 0);
|
||||||
files_e[files_c]->filename = strdup((char *)sqlite3_column_text(res, 1));
|
files_e[files_c]->filename = strdup((char *)sqlite3_column_text(res, 1));
|
||||||
files_e[files_c]->description = strdup((char *)sqlite3_column_text(res, 2));
|
files_e[files_c]->description = strdup((char *)sqlite3_column_text(res, 2));
|
||||||
@ -1514,12 +1508,12 @@ void choose_subdir() {
|
|||||||
for (i = 0; i < conf.file_directories[gUser->cur_file_dir]->file_sub_count; i++) {
|
for (i = 0; i < conf.file_directories[gUser->cur_file_dir]->file_sub_count; i++) {
|
||||||
if (conf.file_directories[gUser->cur_file_dir]->file_subs[i]->download_sec_level <= gUser->sec_level) {
|
if (conf.file_directories[gUser->cur_file_dir]->file_subs[i]->download_sec_level <= gUser->sec_level) {
|
||||||
if (list_tmp == 0) {
|
if (list_tmp == 0) {
|
||||||
sub_tmp = (struct subdir_tmp_t **)malloc(sizeof(struct subdir_tmp_t *));
|
sub_tmp = (struct subdir_tmp_t **)malloz(sizeof(struct subdir_tmp_t *));
|
||||||
} else {
|
} else {
|
||||||
sub_tmp = (struct subdir_tmp_t **)realloc(sub_tmp, sizeof(struct subdir_tmp_t *) * (list_tmp + 1));
|
sub_tmp = (struct subdir_tmp_t **)realloc(sub_tmp, sizeof(struct subdir_tmp_t *) * (list_tmp + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_tmp[list_tmp] = (struct subdir_tmp_t *)malloc(sizeof(struct subdir_tmp_t));
|
sub_tmp[list_tmp] = (struct subdir_tmp_t *)malloz(sizeof(struct subdir_tmp_t));
|
||||||
sub_tmp[list_tmp]->sub = conf.file_directories[gUser->cur_file_dir]->file_subs[i];
|
sub_tmp[list_tmp]->sub = conf.file_directories[gUser->cur_file_dir]->file_subs[i];
|
||||||
sub_tmp[list_tmp]->index = i;
|
sub_tmp[list_tmp]->index = i;
|
||||||
list_tmp++;
|
list_tmp++;
|
||||||
@ -1652,12 +1646,12 @@ void choose_directory() {
|
|||||||
for (i = 0; i < conf.file_directory_count; i++) {
|
for (i = 0; i < conf.file_directory_count; i++) {
|
||||||
if (conf.file_directories[i]->sec_level <= gUser->sec_level) {
|
if (conf.file_directories[i]->sec_level <= gUser->sec_level) {
|
||||||
if (list_tmp == 0) {
|
if (list_tmp == 0) {
|
||||||
dir_tmp = (struct dir_tmp_t **)malloc(sizeof(struct dir_tmp_t *));
|
dir_tmp = (struct dir_tmp_t **)malloz(sizeof(struct dir_tmp_t *));
|
||||||
} else {
|
} else {
|
||||||
dir_tmp = (struct dir_tmp_t **)realloc(dir_tmp, sizeof(struct dir_tmp_t *) * (list_tmp + 1));
|
dir_tmp = (struct dir_tmp_t **)realloc(dir_tmp, sizeof(struct dir_tmp_t *) * (list_tmp + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_tmp[list_tmp] = (struct dir_tmp_t *)malloc(sizeof(struct dir_tmp_t));
|
dir_tmp[list_tmp] = (struct dir_tmp_t *)malloz(sizeof(struct dir_tmp_t));
|
||||||
dir_tmp[list_tmp]->dir = conf.file_directories[i];
|
dir_tmp[list_tmp]->dir = conf.file_directories[i];
|
||||||
dir_tmp[list_tmp]->index = i;
|
dir_tmp[list_tmp]->index = i;
|
||||||
list_tmp++;
|
list_tmp++;
|
||||||
|
@ -266,19 +266,11 @@ int l_readMessageHdr(lua_State *L) {
|
|||||||
} else {
|
} else {
|
||||||
for (z = 0; z < jsp->NumFields; z++) {
|
for (z = 0; z < jsp->NumFields; z++) {
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
||||||
subject = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
subject = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memset(subject, 0, jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
||||||
memcpy(subject, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
sender = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
}
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
recipient = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
sender = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(sender, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(sender, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
|
||||||
recipient = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(recipient, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(recipient, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JAM_DelSubPacket(jsp);
|
JAM_DelSubPacket(jsp);
|
||||||
@ -337,7 +329,7 @@ int l_readMessage(lua_State *L) {
|
|||||||
free(jb);
|
free(jb);
|
||||||
body = strdup("No Message");
|
body = strdup("No Message");
|
||||||
} else {
|
} else {
|
||||||
body = (char *)malloc(jmh.TxtLen + 1);
|
body = (char *)malloz(jmh.TxtLen + 1);
|
||||||
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
|
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
|
||||||
body[jmh.TxtLen] = '\0';
|
body[jmh.TxtLen] = '\0';
|
||||||
|
|
||||||
@ -522,7 +514,7 @@ int l_postMessage(lua_State *L) {
|
|||||||
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s \r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline);
|
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s \r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = (char *)malloc(strlen(body) + 2 + strlen(buffer));
|
msg = (char *)malloz(strlen(body) + 2 + strlen(buffer));
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
@ -531,8 +523,8 @@ int l_postMessage(lua_State *L) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
msg[j++] = body[i];
|
msg[j++] = body[i];
|
||||||
msg[j] = '\0';
|
|
||||||
}
|
}
|
||||||
|
msg[j] = '\0';
|
||||||
|
|
||||||
strcat(msg, buffer);
|
strcat(msg, buffer);
|
||||||
|
|
||||||
|
115
src/mail_menu.c
115
src/mail_menu.c
@ -143,8 +143,7 @@ int msg_is_to(struct user_record *user, char *addressed_to, char *address, int t
|
|||||||
int j;
|
int j;
|
||||||
int magi_dest;
|
int magi_dest;
|
||||||
if (rn) {
|
if (rn) {
|
||||||
myname = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
|
myname = str3dup(user->firstname, " ", user->lastname);
|
||||||
sprintf(myname, "%s %s", user->firstname, user->lastname);
|
|
||||||
} else {
|
} else {
|
||||||
myname = strdup(user->loginname);
|
myname = strdup(user->loginname);
|
||||||
}
|
}
|
||||||
@ -190,8 +189,7 @@ int msg_is_from(struct user_record *user, char *addressed_from, char *address, i
|
|||||||
int magi_orig;
|
int magi_orig;
|
||||||
|
|
||||||
if (rn) {
|
if (rn) {
|
||||||
myname = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
|
myname = str3dup(user->firstname, " ", user->lastname);
|
||||||
sprintf(myname, "%s %s", user->firstname, user->lastname);
|
|
||||||
} else {
|
} else {
|
||||||
myname = strdup(user->loginname);
|
myname = strdup(user->loginname);
|
||||||
}
|
}
|
||||||
@ -254,7 +252,7 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
|||||||
JAM_ReadMBHeader(jb, &jbh);
|
JAM_ReadMBHeader(jb, &jbh);
|
||||||
|
|
||||||
if (jbh.ActiveMsgs > 0) {
|
if (jbh.ActiveMsgs > 0) {
|
||||||
msghs = (struct msg_headers *)malloc(sizeof(struct msg_headers));
|
msghs = (struct msg_headers *)malloz(sizeof(struct msg_headers));
|
||||||
msghs->msg_count = 0;
|
msghs->msg_count = 0;
|
||||||
k = 0;
|
k = 0;
|
||||||
for (i = 0; k < jbh.ActiveMsgs; i++) {
|
for (i = 0; k < jbh.ActiveMsgs; i++) {
|
||||||
@ -271,10 +269,10 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
jamm = (struct jam_msg *)malloc(sizeof(struct jam_msg));
|
jamm = (struct jam_msg *)malloz(sizeof(struct jam_msg));
|
||||||
|
|
||||||
jamm->msg_no = i;
|
jamm->msg_no = i;
|
||||||
jamm->msg_h = (s_JamMsgHeader *)malloc(sizeof(s_JamMsgHeader));
|
jamm->msg_h = (s_JamMsgHeader *)malloz(sizeof(s_JamMsgHeader));
|
||||||
memcpy(jamm->msg_h, &jmh, sizeof(s_JamMsgHeader));
|
memcpy(jamm->msg_h, &jmh, sizeof(s_JamMsgHeader));
|
||||||
jamm->from = NULL;
|
jamm->from = NULL;
|
||||||
jamm->to = NULL;
|
jamm->to = NULL;
|
||||||
@ -286,39 +284,19 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
|||||||
|
|
||||||
for (z = 0; z < jsp->NumFields; z++) {
|
for (z = 0; z < jsp->NumFields; z++) {
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
||||||
jamm->subject = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
jamm->subject = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memset(jamm->subject, 0, jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
||||||
memcpy(jamm->subject, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
jamm->from = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
}
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
jamm->to = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
jamm->from = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
|
||||||
memset(jamm->from, 0, jsp->Fields[z]->DatLen + 1);
|
jamm->daddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memcpy(jamm->from, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
|
||||||
}
|
jamm->oaddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
||||||
jamm->to = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
jamm->msgid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memset(jamm->to, 0, jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
||||||
memcpy(jamm->to, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
jamm->replyid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
|
|
||||||
jamm->daddress = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(jamm->daddress, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(jamm->daddress, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
|
|
||||||
jamm->oaddress = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(jamm->oaddress, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(jamm->oaddress, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
|
||||||
jamm->msgid = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(jamm->msgid, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(jamm->msgid, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
|
||||||
jamm->replyid = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(jamm->replyid, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(jamm->replyid, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JAM_DelSubPacket(jsp);
|
JAM_DelSubPacket(jsp);
|
||||||
@ -397,7 +375,7 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msghs->msg_count == 0) {
|
if (msghs->msg_count == 0) {
|
||||||
msghs->msgs = (struct jam_msg **)malloc(sizeof(struct jam_msg *));
|
msghs->msgs = (struct jam_msg **)malloz(sizeof(struct jam_msg *));
|
||||||
} else {
|
} else {
|
||||||
msghs->msgs = (struct jam_msg **)realloc(msghs->msgs, sizeof(struct jam_msg *) * (msghs->msg_count + 1));
|
msghs->msgs = (struct jam_msg **)realloc(msghs->msgs, sizeof(struct jam_msg *) * (msghs->msg_count + 1));
|
||||||
}
|
}
|
||||||
@ -511,7 +489,7 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
|
|||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
totlen += len;
|
totlen += len;
|
||||||
if (body == NULL) {
|
if (body == NULL) {
|
||||||
body = (char *)malloc(totlen + 1);
|
body = (char *)malloz(totlen + 1);
|
||||||
} else {
|
} else {
|
||||||
body = (char *)realloc(body, totlen + 1);
|
body = (char *)realloc(body, totlen + 1);
|
||||||
}
|
}
|
||||||
@ -556,12 +534,12 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
|
|||||||
snprintf(buffer, 256, "\r");
|
snprintf(buffer, 256, "\r");
|
||||||
}
|
}
|
||||||
if (user->autosig) {
|
if (user->autosig) {
|
||||||
body2 = (char *)malloc(totlen + 3 + strlen(buffer) + strlen(user->signature));
|
body2 = (char *)malloz(totlen + 3 + strlen(buffer) + strlen(user->signature));
|
||||||
} else {
|
} else {
|
||||||
body2 = (char *)malloc(totlen + 2 + strlen(buffer));
|
body2 = (char *)malloz(totlen + 2 + strlen(buffer));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body2 = (char *)malloc(totlen + 1);
|
body2 = (char *)malloz(totlen + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
@ -616,12 +594,12 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
|
|||||||
for (i = 0; i < quotelen; i++) {
|
for (i = 0; i < quotelen; i++) {
|
||||||
if (quote[i] == '\r' || lineat == 67) {
|
if (quote[i] == '\r' || lineat == 67) {
|
||||||
if (quotelines == 0) {
|
if (quotelines == 0) {
|
||||||
quotecontent = (char **)malloc(sizeof(char *));
|
quotecontent = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
quotecontent = (char **)realloc(quotecontent, sizeof(char *) * (quotelines + 1));
|
quotecontent = (char **)realloc(quotecontent, sizeof(char *) * (quotelines + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
quotecontent[quotelines] = (char *)malloc(strlen(linebuffer) + 4);
|
quotecontent[quotelines] = (char *)malloz(strlen(linebuffer) + 4);
|
||||||
sprintf(quotecontent[quotelines], "%c> %s", from[0], linebuffer);
|
sprintf(quotecontent[quotelines], "%c> %s", from[0], linebuffer);
|
||||||
quotelines++;
|
quotelines++;
|
||||||
lineat = 0;
|
lineat = 0;
|
||||||
@ -704,8 +682,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
|
|||||||
size += 1;
|
size += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = (char *)malloc(size);
|
msg = (char *)malloz(size);
|
||||||
memset(msg, 0, size);
|
|
||||||
for (i = 0; i < lines; i++) {
|
for (i = 0; i < lines; i++) {
|
||||||
strcat(msg, content[i]);
|
strcat(msg, content[i]);
|
||||||
strcat(msg, "\r");
|
strcat(msg, "\r");
|
||||||
@ -773,7 +750,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
|
|||||||
|
|
||||||
for (i = qfrom; i <= qto; i++) {
|
for (i = qfrom; i <= qto; i++) {
|
||||||
if (lines == 0) {
|
if (lines == 0) {
|
||||||
content = (char **)malloc(sizeof(char *));
|
content = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
content = (char **)realloc(content, sizeof(char *) * (lines + 1));
|
content = (char **)realloc(content, sizeof(char *) * (lines + 1));
|
||||||
}
|
}
|
||||||
@ -866,7 +843,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lines == 0) {
|
if (lines == 0) {
|
||||||
content = (char **)malloc(sizeof(char *));
|
content = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
content = (char **)realloc(content, sizeof(char *) * (lines + 1));
|
content = (char **)realloc(content, sizeof(char *) * (lines + 1));
|
||||||
}
|
}
|
||||||
@ -1055,11 +1032,11 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fake_screen = (struct character_t ***)malloc(sizeof(struct character_t **) * line_count);
|
fake_screen = (struct character_t ***)malloz(sizeof(struct character_t **) * line_count);
|
||||||
for (i = 0; i < line_count; i++) {
|
for (i = 0; i < line_count; i++) {
|
||||||
fake_screen[i] = (struct character_t **)malloc(sizeof(struct character_t *) * 80);
|
fake_screen[i] = (struct character_t **)malloz(sizeof(struct character_t *) * 80);
|
||||||
for (j = 0; j < 80; j++) {
|
for (j = 0; j < 80; j++) {
|
||||||
fake_screen[i][j] = (struct character_t *)malloc(sizeof(struct character_t));
|
fake_screen[i][j] = (struct character_t *)malloz(sizeof(struct character_t));
|
||||||
fake_screen[i][j]->c = ' ';
|
fake_screen[i][j]->c = ' ';
|
||||||
fake_screen[i][j]->fg = fg;
|
fake_screen[i][j]->fg = fg;
|
||||||
fake_screen[i][j]->bg = bg;
|
fake_screen[i][j]->bg = bg;
|
||||||
@ -1376,7 +1353,7 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
|||||||
|
|
||||||
out_max = 256;
|
out_max = 256;
|
||||||
out_len = 0;
|
out_len = 0;
|
||||||
out = (char *)malloc(256);
|
out = (char *)malloz(256);
|
||||||
|
|
||||||
for (i = 0; i < line_count; i++) {
|
for (i = 0; i < line_count; i++) {
|
||||||
buf_at = 0;
|
buf_at = 0;
|
||||||
@ -1585,7 +1562,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
|||||||
s_printf(get_string(110), (msghs->msgs[mailno]->msg_h->Attribute & JAM_MSG_SENT ? "SENT" : ""), (msgbase_is_flagged(user, user->cur_mail_conf, user->cur_mail_area, msghs->msgs[mailno]->msg_h->MsgNum) ? "FLAGGED" : ""));
|
s_printf(get_string(110), (msghs->msgs[mailno]->msg_h->Attribute & JAM_MSG_SENT ? "SENT" : ""), (msgbase_is_flagged(user, user->cur_mail_conf, user->cur_mail_area, msghs->msgs[mailno]->msg_h->MsgNum) ? "FLAGGED" : ""));
|
||||||
s_printf(get_string(111));
|
s_printf(get_string(111));
|
||||||
|
|
||||||
body = (char *)malloc(msghs->msgs[mailno]->msg_h->TxtLen);
|
body = (char *)malloz(msghs->msgs[mailno]->msg_h->TxtLen);
|
||||||
|
|
||||||
JAM_ReadMsgText(jb, msghs->msgs[mailno]->msg_h->TxtOffset, msghs->msgs[mailno]->msg_h->TxtLen, (char *)body);
|
JAM_ReadMsgText(jb, msghs->msgs[mailno]->msg_h->TxtOffset, msghs->msgs[mailno]->msg_h->TxtLen, (char *)body);
|
||||||
if (!newscan) {
|
if (!newscan) {
|
||||||
@ -1609,12 +1586,12 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
|||||||
for (z = 0; z < z2; z++) {
|
for (z = 0; z < z2; z++) {
|
||||||
if (body[z] == '\r' || chars == 80) {
|
if (body[z] == '\r' || chars == 80) {
|
||||||
if (msg_line_count == 0) {
|
if (msg_line_count == 0) {
|
||||||
msg_lines = (char **)malloc(sizeof(char *));
|
msg_lines = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
msg_lines = (char **)realloc(msg_lines, sizeof(char *) * (msg_line_count + 1));
|
msg_lines = (char **)realloc(msg_lines, sizeof(char *) * (msg_line_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_lines[msg_line_count] = (char *)malloc(sizeof(char) * (z - start_line + 1));
|
msg_lines[msg_line_count] = (char *)malloz(sizeof(char) * (z - start_line + 1));
|
||||||
|
|
||||||
if (z == start_line) {
|
if (z == start_line) {
|
||||||
msg_lines[msg_line_count][0] = '\0';
|
msg_lines[msg_line_count][0] = '\0';
|
||||||
@ -1723,8 +1700,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
|||||||
snprintf(buffer, 256, "%s", msghs->msgs[mailno]->subject);
|
snprintf(buffer, 256, "%s", msghs->msgs[mailno]->subject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subject = (char *)malloc(strlen(buffer) + 1);
|
subject = strdup(buffer);
|
||||||
strcpy(subject, buffer);
|
|
||||||
|
|
||||||
s_printf(get_string(114));
|
s_printf(get_string(114));
|
||||||
s_readstring_inject(buffer, 32, msghs->msgs[mailno]->from);
|
s_readstring_inject(buffer, 32, msghs->msgs[mailno]->from);
|
||||||
@ -1740,15 +1716,13 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
|||||||
strcpy(buffer, msghs->msgs[mailno]->from);
|
strcpy(buffer, msghs->msgs[mailno]->from);
|
||||||
}
|
}
|
||||||
if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) {
|
if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) {
|
||||||
from = (char *)malloc(strlen(user->loginname) + 1);
|
from = strdup(user->loginname);
|
||||||
strcpy(from, user->loginname);
|
|
||||||
} else {
|
} else {
|
||||||
from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
|
from = str3dup(user->firstname, " ", user->lastname);
|
||||||
sprintf(from, "%s %s", user->firstname, user->lastname);
|
|
||||||
}
|
}
|
||||||
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NEWSGROUP_AREA) {
|
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NEWSGROUP_AREA) {
|
||||||
free(to);
|
free(to);
|
||||||
to = (char *)malloc(4);
|
to = (char *)malloz(4);
|
||||||
strcpy(to, "ALL");
|
strcpy(to, "ALL");
|
||||||
}
|
}
|
||||||
replybody = external_editor(user, to, from, body, z2, msghs->msgs[mailno]->from, subject, 0, 0);
|
replybody = external_editor(user, to, from, body, z2, msghs->msgs[mailno]->from, subject, 0, 0);
|
||||||
@ -2221,8 +2195,7 @@ void post_message(struct user_record *user) {
|
|||||||
if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) {
|
if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) {
|
||||||
from = strdup(user->loginname);
|
from = strdup(user->loginname);
|
||||||
} else {
|
} else {
|
||||||
from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
|
from = str3dup(user->firstname, " ", user->lastname);
|
||||||
sprintf(from, "%s %s", user->firstname, user->lastname);
|
|
||||||
}
|
}
|
||||||
msg = external_editor(user, to, from, NULL, 0, NULL, subject, 0, 0);
|
msg = external_editor(user, to, from, NULL, 0, NULL, subject, 0, 0);
|
||||||
|
|
||||||
@ -2757,12 +2730,12 @@ void choose_conference() {
|
|||||||
for (i = 0; i < conf.mail_conference_count; i++) {
|
for (i = 0; i < conf.mail_conference_count; i++) {
|
||||||
if (conf.mail_conferences[i]->sec_level <= gUser->sec_level) {
|
if (conf.mail_conferences[i]->sec_level <= gUser->sec_level) {
|
||||||
if (list_tmp == 0) {
|
if (list_tmp == 0) {
|
||||||
conf_tmp = (struct conf_tmp_t **)malloc(sizeof(struct conf_tmp_t *));
|
conf_tmp = (struct conf_tmp_t **)malloz(sizeof(struct conf_tmp_t *));
|
||||||
} else {
|
} else {
|
||||||
conf_tmp = (struct conf_tmp_t **)realloc(conf_tmp, sizeof(struct conf_tmp_t *) * (list_tmp + 1));
|
conf_tmp = (struct conf_tmp_t **)realloc(conf_tmp, sizeof(struct conf_tmp_t *) * (list_tmp + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf_tmp[list_tmp] = (struct conf_tmp_t *)malloc(sizeof(struct conf_tmp_t));
|
conf_tmp[list_tmp] = (struct conf_tmp_t *)malloz(sizeof(struct conf_tmp_t));
|
||||||
conf_tmp[list_tmp]->conference = conf.mail_conferences[i];
|
conf_tmp[list_tmp]->conference = conf.mail_conferences[i];
|
||||||
conf_tmp[list_tmp]->index = i;
|
conf_tmp[list_tmp]->index = i;
|
||||||
list_tmp++;
|
list_tmp++;
|
||||||
@ -2903,12 +2876,12 @@ void choose_area() {
|
|||||||
for (i = 0; i < conf.mail_conferences[gUser->cur_mail_conf]->mail_area_count; i++) {
|
for (i = 0; i < conf.mail_conferences[gUser->cur_mail_conf]->mail_area_count; i++) {
|
||||||
if (conf.mail_conferences[gUser->cur_mail_conf]->mail_areas[i]->read_sec_level <= gUser->sec_level) {
|
if (conf.mail_conferences[gUser->cur_mail_conf]->mail_areas[i]->read_sec_level <= gUser->sec_level) {
|
||||||
if (list_tmp == 0) {
|
if (list_tmp == 0) {
|
||||||
area_tmp = (struct area_tmp_t **)malloc(sizeof(struct area_tmp_t *));
|
area_tmp = (struct area_tmp_t **)malloz(sizeof(struct area_tmp_t *));
|
||||||
} else {
|
} else {
|
||||||
area_tmp = (struct area_tmp_t **)realloc(area_tmp, sizeof(struct area_tmp_t *) * (list_tmp + 1));
|
area_tmp = (struct area_tmp_t **)realloc(area_tmp, sizeof(struct area_tmp_t *) * (list_tmp + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
area_tmp[list_tmp] = (struct area_tmp_t *)malloc(sizeof(struct area_tmp_t));
|
area_tmp[list_tmp] = (struct area_tmp_t *)malloz(sizeof(struct area_tmp_t));
|
||||||
area_tmp[list_tmp]->area = conf.mail_conferences[gUser->cur_mail_conf]->mail_areas[i];
|
area_tmp[list_tmp]->area = conf.mail_conferences[gUser->cur_mail_conf]->mail_areas[i];
|
||||||
area_tmp[list_tmp]->index = i;
|
area_tmp[list_tmp]->index = i;
|
||||||
list_tmp++;
|
list_tmp++;
|
||||||
|
43
src/main.c
43
src/main.c
@ -116,12 +116,12 @@ static int protocol_config_handler(void *user, const char *section, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf->protocol_count == 0) {
|
if (conf->protocol_count == 0) {
|
||||||
conf->protocols = (struct protocol **)malloc(sizeof(struct protocol *));
|
conf->protocols = (struct protocol **)malloz(sizeof(struct protocol *));
|
||||||
} else {
|
} else {
|
||||||
conf->protocols = (struct protocol **)realloc(conf->protocols, sizeof(struct protocol *) * (conf->protocol_count + 1));
|
conf->protocols = (struct protocol **)realloc(conf->protocols, sizeof(struct protocol *) * (conf->protocol_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->protocols[conf->protocol_count] = (struct protocol *)malloc(sizeof(struct protocol));
|
conf->protocols[conf->protocol_count] = (struct protocol *)malloz(sizeof(struct protocol));
|
||||||
|
|
||||||
conf->protocols[conf->protocol_count]->name = strdup(section);
|
conf->protocols[conf->protocol_count]->name = strdup(section);
|
||||||
conf->protocols[conf->protocol_count]->internal_zmodem = 0;
|
conf->protocols[conf->protocol_count]->internal_zmodem = 0;
|
||||||
@ -176,12 +176,12 @@ static int archiver_config_handler(void *user, const char *section, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf->archiver_count == 0) {
|
if (conf->archiver_count == 0) {
|
||||||
conf->archivers = (struct archiver **)malloc(sizeof(struct archiver *));
|
conf->archivers = (struct archiver **)malloz(sizeof(struct archiver *));
|
||||||
} else {
|
} else {
|
||||||
conf->archivers = (struct archiver **)realloc(conf->archivers, sizeof(struct archiver *) * (conf->archiver_count + 1));
|
conf->archivers = (struct archiver **)realloc(conf->archivers, sizeof(struct archiver *) * (conf->archiver_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->archivers[conf->archiver_count] = (struct archiver *)malloc(sizeof(struct archiver));
|
conf->archivers[conf->archiver_count] = (struct archiver *)malloz(sizeof(struct archiver));
|
||||||
|
|
||||||
conf->archivers[conf->archiver_count]->name = strdup(section);
|
conf->archivers[conf->archiver_count]->name = strdup(section);
|
||||||
|
|
||||||
@ -221,12 +221,12 @@ static int door_config_handler(void *user, const char *section, const char *name
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf->door_count == 0) {
|
if (conf->door_count == 0) {
|
||||||
conf->doors = (struct door_config **)malloc(sizeof(struct door_config *));
|
conf->doors = (struct door_config **)malloz(sizeof(struct door_config *));
|
||||||
} else {
|
} else {
|
||||||
conf->doors = (struct door_config **)realloc(conf->doors, sizeof(struct door_config *) * (conf->door_count + 1));
|
conf->doors = (struct door_config **)realloc(conf->doors, sizeof(struct door_config *) * (conf->door_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->doors[conf->door_count] = (struct door_config *)malloc(sizeof(struct door_config));
|
conf->doors[conf->door_count] = (struct door_config *)malloz(sizeof(struct door_config));
|
||||||
|
|
||||||
conf->doors[conf->door_count]->name = strdup(section);
|
conf->doors[conf->door_count]->name = strdup(section);
|
||||||
conf->doors[conf->door_count]->codepage = NULL;
|
conf->doors[conf->door_count]->codepage = NULL;
|
||||||
@ -279,12 +279,12 @@ static int file_sub_handler(void *user, const char *section, const char *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fd->file_sub_count == 0) {
|
if (fd->file_sub_count == 0) {
|
||||||
fd->file_subs = (struct file_sub **)malloc(sizeof(struct file_sub *));
|
fd->file_subs = (struct file_sub **)malloz(sizeof(struct file_sub *));
|
||||||
} else {
|
} else {
|
||||||
fd->file_subs = (struct file_sub **)realloc(fd->file_subs, sizeof(struct file_sub *) * (fd->file_sub_count + 1));
|
fd->file_subs = (struct file_sub **)realloc(fd->file_subs, sizeof(struct file_sub *) * (fd->file_sub_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
fd->file_subs[fd->file_sub_count] = (struct file_sub *)malloc(sizeof(struct file_sub));
|
fd->file_subs[fd->file_sub_count] = (struct file_sub *)malloz(sizeof(struct file_sub));
|
||||||
|
|
||||||
fd->file_subs[fd->file_sub_count]->name = strdup(section);
|
fd->file_subs[fd->file_sub_count]->name = strdup(section);
|
||||||
if (strcasecmp(name, "upload sec level") == 0) {
|
if (strcasecmp(name, "upload sec level") == 0) {
|
||||||
@ -372,12 +372,12 @@ static int mail_area_handler(void *user, const char *section, const char *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mc->mail_area_count == 0) {
|
if (mc->mail_area_count == 0) {
|
||||||
mc->mail_areas = (struct mail_area **)malloc(sizeof(struct mail_area *));
|
mc->mail_areas = (struct mail_area **)malloz(sizeof(struct mail_area *));
|
||||||
} else {
|
} else {
|
||||||
mc->mail_areas = (struct mail_area **)realloc(mc->mail_areas, sizeof(struct mail_area *) * (mc->mail_area_count + 1));
|
mc->mail_areas = (struct mail_area **)realloc(mc->mail_areas, sizeof(struct mail_area *) * (mc->mail_area_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
mc->mail_areas[mc->mail_area_count] = (struct mail_area *)malloc(sizeof(struct mail_area));
|
mc->mail_areas[mc->mail_area_count] = (struct mail_area *)malloz(sizeof(struct mail_area));
|
||||||
|
|
||||||
mc->mail_areas[mc->mail_area_count]->qwkname = NULL;
|
mc->mail_areas[mc->mail_area_count]->qwkname = NULL;
|
||||||
|
|
||||||
@ -443,8 +443,7 @@ static int handler(void *user, const char *section, const char *name,
|
|||||||
if (value[strlen(value) - 1] == '/') {
|
if (value[strlen(value) - 1] == '/') {
|
||||||
conf->www_url = strdup(value);
|
conf->www_url = strdup(value);
|
||||||
} else {
|
} else {
|
||||||
conf->www_url = (char *)malloc(strlen(value) + 2);
|
conf->www_url = str2dup(value, "/");
|
||||||
sprintf(conf->www_url, "%s/", value);
|
|
||||||
}
|
}
|
||||||
} else if (strcasecmp(name, "ssh port") == 0) {
|
} else if (strcasecmp(name, "ssh port") == 0) {
|
||||||
conf->ssh_port = atoi(value);
|
conf->ssh_port = atoi(value);
|
||||||
@ -566,12 +565,12 @@ static int handler(void *user, const char *section, const char *name,
|
|||||||
}
|
}
|
||||||
} else if (strcasecmp(section, "mail conferences") == 0) {
|
} else if (strcasecmp(section, "mail conferences") == 0) {
|
||||||
if (conf->mail_conference_count == 0) {
|
if (conf->mail_conference_count == 0) {
|
||||||
conf->mail_conferences = (struct mail_conference **)malloc(sizeof(struct mail_conference *));
|
conf->mail_conferences = (struct mail_conference **)malloz(sizeof(struct mail_conference *));
|
||||||
} else {
|
} else {
|
||||||
conf->mail_conferences = (struct mail_conference **)realloc(conf->mail_conferences, sizeof(struct mail_conference *) * (conf->mail_conference_count + 1));
|
conf->mail_conferences = (struct mail_conference **)realloc(conf->mail_conferences, sizeof(struct mail_conference *) * (conf->mail_conference_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->mail_conferences[conf->mail_conference_count] = (struct mail_conference *)malloc(sizeof(struct mail_conference));
|
conf->mail_conferences[conf->mail_conference_count] = (struct mail_conference *)malloz(sizeof(struct mail_conference));
|
||||||
conf->mail_conferences[conf->mail_conference_count]->name = strdup(name);
|
conf->mail_conferences[conf->mail_conference_count]->name = strdup(name);
|
||||||
conf->mail_conferences[conf->mail_conference_count]->path = strdup(value);
|
conf->mail_conferences[conf->mail_conference_count]->path = strdup(value);
|
||||||
conf->mail_conferences[conf->mail_conference_count]->tagline = NULL;
|
conf->mail_conferences[conf->mail_conference_count]->tagline = NULL;
|
||||||
@ -582,12 +581,12 @@ static int handler(void *user, const char *section, const char *name,
|
|||||||
conf->mail_conference_count++;
|
conf->mail_conference_count++;
|
||||||
} else if (strcasecmp(section, "file directories") == 0) {
|
} else if (strcasecmp(section, "file directories") == 0) {
|
||||||
if (conf->file_directory_count == 0) {
|
if (conf->file_directory_count == 0) {
|
||||||
conf->file_directories = (struct file_directory **)malloc(sizeof(struct file_directory *));
|
conf->file_directories = (struct file_directory **)malloz(sizeof(struct file_directory *));
|
||||||
} else {
|
} else {
|
||||||
conf->file_directories = (struct file_directory **)realloc(conf->file_directories, sizeof(struct file_directory *) * (conf->file_directory_count + 1));
|
conf->file_directories = (struct file_directory **)realloc(conf->file_directories, sizeof(struct file_directory *) * (conf->file_directory_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->file_directories[conf->file_directory_count] = (struct file_directory *)malloc(sizeof(struct file_directory));
|
conf->file_directories[conf->file_directory_count] = (struct file_directory *)malloz(sizeof(struct file_directory));
|
||||||
conf->file_directories[conf->file_directory_count]->name = strdup(name);
|
conf->file_directories[conf->file_directory_count]->name = strdup(name);
|
||||||
conf->file_directories[conf->file_directory_count]->path = strdup(value);
|
conf->file_directories[conf->file_directory_count]->path = strdup(value);
|
||||||
conf->file_directories[conf->file_directory_count]->file_sub_count = 0;
|
conf->file_directories[conf->file_directory_count]->file_sub_count = 0;
|
||||||
@ -595,12 +594,12 @@ static int handler(void *user, const char *section, const char *name,
|
|||||||
conf->file_directory_count++;
|
conf->file_directory_count++;
|
||||||
} else if (strcasecmp(section, "text files") == 0) {
|
} else if (strcasecmp(section, "text files") == 0) {
|
||||||
if (conf->text_file_count == 0) {
|
if (conf->text_file_count == 0) {
|
||||||
conf->text_files = (struct text_file **)malloc(sizeof(struct text_file *));
|
conf->text_files = (struct text_file **)malloz(sizeof(struct text_file *));
|
||||||
} else {
|
} else {
|
||||||
conf->text_files = (struct text_file **)realloc(conf->text_files, sizeof(struct text_file *) * (conf->text_file_count + 1));
|
conf->text_files = (struct text_file **)realloc(conf->text_files, sizeof(struct text_file *) * (conf->text_file_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->text_files[conf->text_file_count] = (struct text_file *)malloc(sizeof(struct text_file));
|
conf->text_files[conf->text_file_count] = (struct text_file *)malloz(sizeof(struct text_file));
|
||||||
conf->text_files[conf->text_file_count]->name = strdup(name);
|
conf->text_files[conf->text_file_count]->name = strdup(name);
|
||||||
conf->text_files[conf->text_file_count]->path = strdup(value);
|
conf->text_files[conf->text_file_count]->path = strdup(value);
|
||||||
conf->text_file_count++;
|
conf->text_file_count++;
|
||||||
@ -845,7 +844,7 @@ void serverssh(int port, int ipv6) {
|
|||||||
i = hashmap_get(ip_guard_map, ip, (void **)(&ip_guard));
|
i = hashmap_get(ip_guard_map, ip, (void **)(&ip_guard));
|
||||||
|
|
||||||
if (i == MAP_MISSING) {
|
if (i == MAP_MISSING) {
|
||||||
ip_guard = (struct ip_address_guard *)malloc(sizeof(struct ip_address_guard));
|
ip_guard = (struct ip_address_guard *)malloz(sizeof(struct ip_address_guard));
|
||||||
ip_guard->status = IP_STATUS_UNKNOWN;
|
ip_guard->status = IP_STATUS_UNKNOWN;
|
||||||
ip_guard->last_connection = time(NULL);
|
ip_guard->last_connection = time(NULL);
|
||||||
ip_guard->connection_count = 1;
|
ip_guard->connection_count = 1;
|
||||||
@ -1026,7 +1025,7 @@ void server(int port, int ipv6) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_guard = (struct ip_address_guard *)malloc(sizeof(struct ip_address_guard));
|
ip_guard = (struct ip_address_guard *)malloz(sizeof(struct ip_address_guard));
|
||||||
ip_guard->status = IP_STATUS_WHITELISTED;
|
ip_guard->status = IP_STATUS_WHITELISTED;
|
||||||
|
|
||||||
hashmap_put(ip_guard_map, strdup(buffer), ip_guard);
|
hashmap_put(ip_guard_map, strdup(buffer), ip_guard);
|
||||||
@ -1049,7 +1048,7 @@ void server(int port, int ipv6) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_guard = (struct ip_address_guard *)malloc(sizeof(struct ip_address_guard));
|
ip_guard = (struct ip_address_guard *)malloz(sizeof(struct ip_address_guard));
|
||||||
ip_guard->status = IP_STATUS_BLACKLISTED;
|
ip_guard->status = IP_STATUS_BLACKLISTED;
|
||||||
|
|
||||||
hashmap_put(ip_guard_map, strdup(buffer), ip_guard);
|
hashmap_put(ip_guard_map, strdup(buffer), ip_guard);
|
||||||
@ -1204,7 +1203,7 @@ void server(int port, int ipv6) {
|
|||||||
i = hashmap_get(ip_guard_map, ip, (void **)(&ip_guard));
|
i = hashmap_get(ip_guard_map, ip, (void **)(&ip_guard));
|
||||||
|
|
||||||
if (i == MAP_MISSING) {
|
if (i == MAP_MISSING) {
|
||||||
ip_guard = (struct ip_address_guard *)malloc(sizeof(struct ip_address_guard));
|
ip_guard = (struct ip_address_guard *)malloz(sizeof(struct ip_address_guard));
|
||||||
ip_guard->status = IP_STATUS_UNKNOWN;
|
ip_guard->status = IP_STATUS_UNKNOWN;
|
||||||
ip_guard->last_connection = time(NULL);
|
ip_guard->last_connection = time(NULL);
|
||||||
ip_guard->connection_count = 1;
|
ip_guard->connection_count = 1;
|
||||||
|
@ -120,11 +120,11 @@ int menu_system(char *menufile) {
|
|||||||
if (strncasecmp(buffer, "HOTKEY", 6) == 0) {
|
if (strncasecmp(buffer, "HOTKEY", 6) == 0) {
|
||||||
menu_items++;
|
menu_items++;
|
||||||
if (menu_items == 1) {
|
if (menu_items == 1) {
|
||||||
menu = (struct menu_item **)malloc(sizeof(struct menu_item *));
|
menu = (struct menu_item **)malloz(sizeof(struct menu_item *));
|
||||||
} else {
|
} else {
|
||||||
menu = (struct menu_item **)realloc(menu, sizeof(struct menu_item *) * (menu_items));
|
menu = (struct menu_item **)realloc(menu, sizeof(struct menu_item *) * (menu_items));
|
||||||
}
|
}
|
||||||
menu[menu_items - 1] = (struct menu_item *)malloc(sizeof(struct menu_item));
|
menu[menu_items - 1] = (struct menu_item *)malloz(sizeof(struct menu_item));
|
||||||
menu[menu_items - 1]->hotkey = buffer[7];
|
menu[menu_items - 1]->hotkey = buffer[7];
|
||||||
menu[menu_items - 1]->command = NULL;
|
menu[menu_items - 1]->command = NULL;
|
||||||
menu[menu_items - 1]->data = NULL;
|
menu[menu_items - 1]->data = NULL;
|
||||||
@ -132,8 +132,8 @@ int menu_system(char *menufile) {
|
|||||||
menu[menu_items - 1]->seclevel = 0;
|
menu[menu_items - 1]->seclevel = 0;
|
||||||
} else if (strncasecmp(buffer, "COMMAND", 7) == 0 && menu_items > 0) {
|
} else if (strncasecmp(buffer, "COMMAND", 7) == 0 && menu_items > 0) {
|
||||||
if (menu[menu_items - 1]->command_count == 0) {
|
if (menu[menu_items - 1]->command_count == 0) {
|
||||||
menu[menu_items - 1]->command = (int *)malloc(sizeof(int));
|
menu[menu_items - 1]->command = (int *)malloz(sizeof(int));
|
||||||
menu[menu_items - 1]->data = (char **)malloc(sizeof(char *));
|
menu[menu_items - 1]->data = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
menu[menu_items - 1]->command = (int *)realloc(menu[menu_items - 1]->command, sizeof(int) * (menu[menu_items - 1]->command_count + 1));
|
menu[menu_items - 1]->command = (int *)realloc(menu[menu_items - 1]->command, sizeof(int) * (menu[menu_items - 1]->command_count + 1));
|
||||||
menu[menu_items - 1]->data = (char **)realloc(menu[menu_items - 1]->data, sizeof(char *) * (menu[menu_items - 1]->command_count + 1));
|
menu[menu_items - 1]->data = (char **)realloc(menu[menu_items - 1]->data, sizeof(char *) * (menu[menu_items - 1]->command_count + 1));
|
||||||
|
@ -97,11 +97,11 @@ void nl_browser() {
|
|||||||
|
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
if (entry_count == 0) {
|
if (entry_count == 0) {
|
||||||
entries = (struct nl_temp **)malloc(sizeof(struct nl_temp *));
|
entries = (struct nl_temp **)malloz(sizeof(struct nl_temp *));
|
||||||
} else {
|
} else {
|
||||||
entries = (struct nl_temp **)realloc(entries, sizeof(struct nl_temp *) * (entry_count + 1));
|
entries = (struct nl_temp **)realloc(entries, sizeof(struct nl_temp *) * (entry_count + 1));
|
||||||
}
|
}
|
||||||
entries[entry_count] = (struct nl_temp *)malloc(sizeof(struct nl_temp));
|
entries[entry_count] = (struct nl_temp *)malloz(sizeof(struct nl_temp));
|
||||||
|
|
||||||
entries[entry_count]->address = strdup(sqlite3_column_text(res, 0));
|
entries[entry_count]->address = strdup(sqlite3_column_text(res, 0));
|
||||||
entries[entry_count]->location = strdup(sqlite3_column_text(res, 1));
|
entries[entry_count]->location = strdup(sqlite3_column_text(res, 1));
|
||||||
@ -235,4 +235,4 @@ void nl_browser() {
|
|||||||
free(entries[i]);
|
free(entries[i]);
|
||||||
}
|
}
|
||||||
free(entries);
|
free(entries);
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,7 @@ void settings_menu(struct user_record *user) {
|
|||||||
s_printf(get_string(160));
|
s_printf(get_string(160));
|
||||||
s_readstring(buffer, 32);
|
s_readstring(buffer, 32);
|
||||||
free(user->location);
|
free(user->location);
|
||||||
user->location = (char *)malloc(strlen(buffer) + 1);
|
user->location = strdup(buffer);
|
||||||
strcpy(user->location, buffer);
|
|
||||||
save_user(user);
|
save_user(user);
|
||||||
} break;
|
} break;
|
||||||
case 'a': {
|
case 'a': {
|
||||||
|
@ -16,7 +16,7 @@ void chomp(char *string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *parse_newlines(char *string) {
|
char *parse_newlines(char *string) {
|
||||||
char *newstring = (char *)malloc(strlen(string) + 1);
|
char *newstring = (char *)malloz(strlen(string) + 1);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < strlen(string); i++) {
|
for (i = 0; i < strlen(string); i++) {
|
||||||
@ -71,7 +71,7 @@ void load_strings() {
|
|||||||
while (!feof(fptr)) {
|
while (!feof(fptr)) {
|
||||||
chomp(buffer);
|
chomp(buffer);
|
||||||
if (string_count == 0) {
|
if (string_count == 0) {
|
||||||
strings = (char **)malloc(sizeof(char *));
|
strings = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
strings = (char **)realloc(strings, sizeof(char *) * (string_count + 1));
|
strings = (char **)realloc(strings, sizeof(char *) * (string_count + 1));
|
||||||
}
|
}
|
||||||
|
21
src/users.c
21
src/users.c
@ -16,18 +16,13 @@ extern struct bbs_config conf;
|
|||||||
extern struct user_record *gUser;
|
extern struct user_record *gUser;
|
||||||
|
|
||||||
char *hash_sha256(char *pass, char *salt) {
|
char *hash_sha256(char *pass, char *salt) {
|
||||||
char *buffer = (char *)malloc(strlen(pass) + strlen(salt) + 1);
|
char *buffer = NULL;
|
||||||
char *shash = NULL;
|
char *shash = NULL;
|
||||||
unsigned char hash[EVP_MAX_MD_SIZE];
|
unsigned char hash[EVP_MAX_MD_SIZE];
|
||||||
unsigned int length_of_hash = 0;
|
unsigned int length_of_hash = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!buffer) {
|
buffer = str2dup(pass, salt);
|
||||||
dolog("Out of memory!");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(buffer, "%s%s", pass, salt);
|
|
||||||
|
|
||||||
EVP_MD_CTX *context = EVP_MD_CTX_new();
|
EVP_MD_CTX *context = EVP_MD_CTX_new();
|
||||||
|
|
||||||
@ -36,7 +31,7 @@ char *hash_sha256(char *pass, char *salt) {
|
|||||||
if (EVP_DigestUpdate(context, buffer, strlen(buffer))) {
|
if (EVP_DigestUpdate(context, buffer, strlen(buffer))) {
|
||||||
if (EVP_DigestFinal_ex(context, hash, &length_of_hash)) {
|
if (EVP_DigestFinal_ex(context, hash, &length_of_hash)) {
|
||||||
|
|
||||||
shash = (char *)malloc(length_of_hash * 2 + 1);
|
shash = (char *)malloz(length_of_hash * 2 + 1);
|
||||||
for (i = 0; i < length_of_hash; i++) {
|
for (i = 0; i < length_of_hash; i++) {
|
||||||
sprintf(shash + (i * 2), "%02x", (int)hash[i]);
|
sprintf(shash + (i * 2), "%02x", (int)hash[i]);
|
||||||
}
|
}
|
||||||
@ -58,7 +53,7 @@ void gen_salt(char **s) {
|
|||||||
FILE *fptr;
|
FILE *fptr;
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
*s = (char *)malloc(11);
|
*s = (char *)malloz(11);
|
||||||
|
|
||||||
char *salt = *s;
|
char *salt = *s;
|
||||||
|
|
||||||
@ -482,7 +477,7 @@ struct user_record *check_user_pass(char *loginname, char *password) {
|
|||||||
int step = sqlite3_step(res);
|
int step = sqlite3_step(res);
|
||||||
|
|
||||||
if (step == SQLITE_ROW) {
|
if (step == SQLITE_ROW) {
|
||||||
user = (struct user_record *)malloc(sizeof(struct user_record));
|
user = (struct user_record *)malloz(sizeof(struct user_record));
|
||||||
user->id = sqlite3_column_int(res, 0);
|
user->id = sqlite3_column_int(res, 0);
|
||||||
user->loginname = strdup((char *)sqlite3_column_text(res, 1));
|
user->loginname = strdup((char *)sqlite3_column_text(res, 1));
|
||||||
user->password = strdup((char *)sqlite3_column_text(res, 2));
|
user->password = strdup((char *)sqlite3_column_text(res, 2));
|
||||||
@ -534,7 +529,7 @@ struct user_record *check_user_pass(char *loginname, char *password) {
|
|||||||
sqlite3_finalize(res);
|
sqlite3_finalize(res);
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
|
|
||||||
user->sec_info = (struct sec_level_t *)malloc(sizeof(struct sec_level_t));
|
user->sec_info = (struct sec_level_t *)malloz(sizeof(struct sec_level_t));
|
||||||
|
|
||||||
snprintf(buffer, 1024, "%s/s%d.ini", conf.config_path, user->sec_level);
|
snprintf(buffer, 1024, "%s/s%d.ini", conf.config_path, user->sec_level);
|
||||||
if (ini_parse(buffer, secLevel, user->sec_info) < 0) {
|
if (ini_parse(buffer, secLevel, user->sec_info) < 0) {
|
||||||
@ -696,7 +691,7 @@ struct user_record *new_user() {
|
|||||||
int i;
|
int i;
|
||||||
int fullnameok = 0;
|
int fullnameok = 0;
|
||||||
|
|
||||||
user = (struct user_record *)malloc(sizeof(struct user_record));
|
user = (struct user_record *)malloz(sizeof(struct user_record));
|
||||||
s_printf("\r\n\r\n");
|
s_printf("\r\n\r\n");
|
||||||
s_displayansi("newuser");
|
s_displayansi("newuser");
|
||||||
|
|
||||||
@ -856,7 +851,7 @@ struct user_record *new_user() {
|
|||||||
} while (!done);
|
} while (!done);
|
||||||
user->sec_level = conf.newuserlvl;
|
user->sec_level = conf.newuserlvl;
|
||||||
user->bwavepktno = 0;
|
user->bwavepktno = 0;
|
||||||
user->sec_info = (struct sec_level_t *)malloc(sizeof(struct sec_level_t));
|
user->sec_info = (struct sec_level_t *)malloz(sizeof(struct sec_level_t));
|
||||||
snprintf(buffer, PATH_MAX, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
snprintf(buffer, PATH_MAX, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
||||||
|
|
||||||
if (ini_parse(buffer, secLevel, user->sec_info) < 0) {
|
if (ini_parse(buffer, secLevel, user->sec_info) < 0) {
|
||||||
|
88
src/util.c
Normal file
88
src/util.c
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "bbs.h"
|
||||||
|
|
||||||
|
void die(const char *msg) {
|
||||||
|
dolog(msg);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *malloz(size_t size) {
|
||||||
|
void *p = malloc(size);
|
||||||
|
if (p == NULL)
|
||||||
|
die("Out of memory");
|
||||||
|
memset(p, 0, size);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *file2str(const char *path) {
|
||||||
|
struct stat s;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
memset(&s, 0, sizeof(s));
|
||||||
|
if (stat(path, &s) < 0)
|
||||||
|
return NULL;
|
||||||
|
if (!S_ISREG(s.st_mode))
|
||||||
|
return NULL;
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return NULL;
|
||||||
|
char *contents = malloz(s.st_size + 1);
|
||||||
|
if (read(fd, contents, s.st_size) != s.st_size) {
|
||||||
|
free(contents);
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
contents[s.st_size] = '\0';
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *str5dup(const char *a, const char *b, const char *c, const char *d, const char *e) {
|
||||||
|
char *p;
|
||||||
|
size_t alen, blen, clen, dlen, elen;
|
||||||
|
|
||||||
|
if (a == NULL)
|
||||||
|
a = "";
|
||||||
|
if (b == NULL)
|
||||||
|
b = "";
|
||||||
|
if (c == NULL)
|
||||||
|
c = "";
|
||||||
|
if (d == NULL)
|
||||||
|
d = "";
|
||||||
|
if (e == NULL)
|
||||||
|
e = "";
|
||||||
|
|
||||||
|
alen = strlen(a);
|
||||||
|
blen = strlen(b);
|
||||||
|
clen = strlen(c);
|
||||||
|
dlen = strlen(d);
|
||||||
|
elen = strlen(e);
|
||||||
|
|
||||||
|
p = malloz(alen + blen + clen + dlen + elen + 1);
|
||||||
|
memmove(p, a, alen);
|
||||||
|
memmove(p + alen, b, blen);
|
||||||
|
memmove(p + alen + blen, c, clen);
|
||||||
|
memmove(p + alen + blen + clen, d, dlen);
|
||||||
|
memmove(p + alen + blen + clen + dlen, e, elen);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *str4dup(const char *a, const char *b, const char *c, const char *d) {
|
||||||
|
return str5dup(a, b, c, d, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *str3dup(const char *a, const char *b, const char *c) {
|
||||||
|
return str5dup(a, b, c, "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *str2dup(const char *a, const char *b) {
|
||||||
|
return str5dup(a, b, "", "", "");
|
||||||
|
}
|
236
src/www.c
236
src/www.c
@ -44,10 +44,10 @@ void *www_logger(void *cls, const char *uri, struct MHD_Connection *con) {
|
|||||||
struct sockaddr *so = (struct sockaddr *)MHD_get_connection_info(con, MHD_CONNECTION_INFO_CLIENT_ADDRESS)->client_addr;
|
struct sockaddr *so = (struct sockaddr *)MHD_get_connection_info(con, MHD_CONNECTION_INFO_CLIENT_ADDRESS)->client_addr;
|
||||||
char *ipaddr;
|
char *ipaddr;
|
||||||
if (so->sa_family == AF_INET) {
|
if (so->sa_family == AF_INET) {
|
||||||
ipaddr = (char *)malloc(INET_ADDRSTRLEN + 1);
|
ipaddr = (char *)malloz(INET_ADDRSTRLEN + 1);
|
||||||
inet_ntop(AF_INET, &((struct sockaddr_in *)so)->sin_addr, ipaddr, INET_ADDRSTRLEN);
|
inet_ntop(AF_INET, &((struct sockaddr_in *)so)->sin_addr, ipaddr, INET_ADDRSTRLEN);
|
||||||
} else if (so->sa_family == AF_INET6) {
|
} else if (so->sa_family == AF_INET6) {
|
||||||
ipaddr = (char *)malloc(INET6_ADDRSTRLEN + 1);
|
ipaddr = (char *)malloz(INET6_ADDRSTRLEN + 1);
|
||||||
inet_ntop(AF_INET6, &((struct sockaddr_in6 *)so)->sin6_addr, ipaddr, INET6_ADDRSTRLEN);
|
inet_ntop(AF_INET6, &((struct sockaddr_in6 *)so)->sin6_addr, ipaddr, INET6_ADDRSTRLEN);
|
||||||
}
|
}
|
||||||
dolog_www(ipaddr, "%s", uri);
|
dolog_www(ipaddr, "%s", uri);
|
||||||
@ -114,8 +114,8 @@ static int iterate_post(void *coninfo_cls, enum MHD_ValueKind kind, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (con_info->count == 0) {
|
if (con_info->count == 0) {
|
||||||
con_info->keys = (char **)malloc(sizeof(char *));
|
con_info->keys = (char **)malloz(sizeof(char *));
|
||||||
con_info->values = (char **)malloc(sizeof(char *));
|
con_info->values = (char **)malloz(sizeof(char *));
|
||||||
} else {
|
} else {
|
||||||
con_info->keys = (char **)realloc(con_info->keys, sizeof(char *) * (con_info->count + 1));
|
con_info->keys = (char **)realloc(con_info->keys, sizeof(char *) * (con_info->count + 1));
|
||||||
con_info->values = (char **)realloc(con_info->values, sizeof(char *) * (con_info->count + 1));
|
con_info->values = (char **)realloc(con_info->values, sizeof(char *) * (con_info->count + 1));
|
||||||
@ -153,12 +153,12 @@ void www_init() {
|
|||||||
if (buffer[i] == ' ') {
|
if (buffer[i] == ' ') {
|
||||||
buffer[i] = '\0';
|
buffer[i] = '\0';
|
||||||
if (mime_types_count == 0) {
|
if (mime_types_count == 0) {
|
||||||
mime_types = (struct mime_type **)malloc(sizeof(struct mime_type *));
|
mime_types = (struct mime_type **)malloz(sizeof(struct mime_type *));
|
||||||
} else {
|
} else {
|
||||||
mime_types = (struct mime_type **)realloc(mime_types, sizeof(struct mime_type *) * (mime_types_count + 1));
|
mime_types = (struct mime_type **)realloc(mime_types, sizeof(struct mime_type *) * (mime_types_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
mime_types[mime_types_count] = (struct mime_type *)malloc(sizeof(struct mime_type));
|
mime_types[mime_types_count] = (struct mime_type *)malloz(sizeof(struct mime_type));
|
||||||
|
|
||||||
mime_types[mime_types_count]->mime = strdup(buffer);
|
mime_types[mime_types_count]->mime = strdup(buffer);
|
||||||
mime_types[mime_types_count]->ext = strdup(&buffer[i + 1]);
|
mime_types[mime_types_count]->ext = strdup(&buffer[i + 1]);
|
||||||
@ -193,7 +193,6 @@ char *www_get_mime_type(const char *extension) {
|
|||||||
int www_401(char *header, char *footer, struct MHD_Connection *connection) {
|
int www_401(char *header, char *footer, struct MHD_Connection *connection) {
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
char *page, *page_tmp;
|
char *page, *page_tmp;
|
||||||
struct stat s;
|
|
||||||
char *whole_page;
|
char *whole_page;
|
||||||
struct MHD_Response *response;
|
struct MHD_Response *response;
|
||||||
int ret;
|
int ret;
|
||||||
@ -201,38 +200,19 @@ int www_401(char *header, char *footer, struct MHD_Connection *connection) {
|
|||||||
|
|
||||||
snprintf(buffer, PATH_MAX, "%s/401.tpl", conf.www_path);
|
snprintf(buffer, PATH_MAX, "%s/401.tpl", conf.www_path);
|
||||||
|
|
||||||
page_tmp = NULL;
|
page_tmp = file2str(buffer);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
|
||||||
page_tmp = (char *)malloc(s.st_size + 1);
|
|
||||||
if (page_tmp == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memset(page_tmp, 0, s.st_size + 1);
|
|
||||||
fptr = fopen(buffer, "r");
|
|
||||||
if (fptr) {
|
|
||||||
fread(page_tmp, s.st_size, 1, fptr);
|
|
||||||
fclose(fptr);
|
|
||||||
} else {
|
|
||||||
free(page_tmp);
|
|
||||||
page_tmp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
page_tmp = (char *)malloc(16);
|
page_tmp = strdup("Missing Content");
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sprintf(page_tmp, "Missing Content");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
||||||
free(page_tmp);
|
free(page_tmp);
|
||||||
|
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
|
|
||||||
response = MHD_create_response_from_buffer(strlen(whole_page), (void *)whole_page, MHD_RESPMEM_MUST_FREE);
|
response = MHD_create_response_from_buffer(strlen(whole_page), (void *)whole_page, MHD_RESPMEM_MUST_FREE);
|
||||||
|
|
||||||
@ -256,38 +236,19 @@ int www_404(char *header, char *footer, struct MHD_Connection *connection) {
|
|||||||
|
|
||||||
snprintf(buffer, PATH_MAX, "%s/404.tpl", conf.www_path);
|
snprintf(buffer, PATH_MAX, "%s/404.tpl", conf.www_path);
|
||||||
|
|
||||||
page_tmp = NULL;
|
page_tmp = file2str(buffer);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
|
||||||
page_tmp = (char *)malloc(s.st_size + 1);
|
|
||||||
if (page_tmp == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memset(page_tmp, 0, s.st_size + 1);
|
|
||||||
fptr = fopen(buffer, "r");
|
|
||||||
if (fptr) {
|
|
||||||
fread(page_tmp, s.st_size, 1, fptr);
|
|
||||||
fclose(fptr);
|
|
||||||
} else {
|
|
||||||
free(page_tmp);
|
|
||||||
page = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
page_tmp = (char *)malloc(16);
|
page_tmp = (char *)strdup("Missing Content");
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sprintf(page_tmp, "Missing Content");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
||||||
free(page_tmp);
|
free(page_tmp);
|
||||||
|
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
|
|
||||||
response = MHD_create_response_from_buffer(strlen(whole_page), (void *)whole_page, MHD_RESPMEM_MUST_FREE);
|
response = MHD_create_response_from_buffer(strlen(whole_page), (void *)whole_page, MHD_RESPMEM_MUST_FREE);
|
||||||
|
|
||||||
@ -310,38 +271,19 @@ int www_403(char *header, char *footer, struct MHD_Connection *connection) {
|
|||||||
|
|
||||||
snprintf(buffer, PATH_MAX, "%s/403.tpl", conf.www_path);
|
snprintf(buffer, PATH_MAX, "%s/403.tpl", conf.www_path);
|
||||||
|
|
||||||
page_tmp = NULL;
|
page_tmp = file2str(buffer);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
|
||||||
page_tmp = (char *)malloc(s.st_size + 1);
|
|
||||||
if (page_tmp == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memset(page_tmp, 0, s.st_size + 1);
|
|
||||||
fptr = fopen(buffer, "r");
|
|
||||||
if (fptr) {
|
|
||||||
fread(page_tmp, s.st_size, 1, fptr);
|
|
||||||
fclose(fptr);
|
|
||||||
} else {
|
|
||||||
free(page_tmp);
|
|
||||||
page_tmp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
page_tmp = (char *)malloc(16);
|
page_tmp = strdup("Missing Content");
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sprintf(page_tmp, "Missing Content");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
||||||
free(page_tmp);
|
free(page_tmp);
|
||||||
|
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
|
|
||||||
response = MHD_create_response_from_buffer(strlen(whole_page), (void *)whole_page, MHD_RESPMEM_MUST_FREE);
|
response = MHD_create_response_from_buffer(strlen(whole_page), (void *)whole_page, MHD_RESPMEM_MUST_FREE);
|
||||||
|
|
||||||
@ -428,7 +370,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
|
|
||||||
if (strcmp(method, "GET") == 0) {
|
if (strcmp(method, "GET") == 0) {
|
||||||
if (*ptr == NULL) {
|
if (*ptr == NULL) {
|
||||||
con_inf = (struct connection_info_s *)malloc(sizeof(struct connection_info_s));
|
con_inf = (struct connection_info_s *)malloz(sizeof(struct connection_info_s));
|
||||||
if (!con_inf) {
|
if (!con_inf) {
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
@ -442,7 +384,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
}
|
}
|
||||||
} else if (strcmp(method, "POST") == 0) {
|
} else if (strcmp(method, "POST") == 0) {
|
||||||
if (*ptr == NULL) {
|
if (*ptr == NULL) {
|
||||||
con_inf = (struct connection_info_s *)malloc(sizeof(struct connection_info_s));
|
con_inf = (struct connection_info_s *)malloz(sizeof(struct connection_info_s));
|
||||||
if (!con_inf) {
|
if (!con_inf) {
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
@ -462,30 +404,13 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
|
|
||||||
snprintf(buffer, PATH_MAX, "%s/header.tpl", conf.www_path);
|
snprintf(buffer, PATH_MAX, "%s/header.tpl", conf.www_path);
|
||||||
|
|
||||||
header_tmp = NULL;
|
header_tmp = file2str(buffer);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
|
||||||
header_tmp = (char *)malloc(s.st_size + 1);
|
|
||||||
if (header_tmp == NULL) {
|
|
||||||
return MHD_NO;
|
|
||||||
}
|
|
||||||
memset(header_tmp, 0, s.st_size + 1);
|
|
||||||
fptr = fopen(buffer, "r");
|
|
||||||
if (fptr) {
|
|
||||||
fread(header_tmp, s.st_size, 1, fptr);
|
|
||||||
fclose(fptr);
|
|
||||||
} else {
|
|
||||||
free(header_tmp);
|
|
||||||
header_tmp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (header_tmp == NULL) {
|
if (header_tmp == NULL) {
|
||||||
header_tmp = (char *)malloc(strlen(conf.bbs_name) * 2 + 61);
|
header_tmp = str5dup("<HTML>\n<HEAD>\n<TITLE>", conf.bbs_name, "</TITLE>\n</HEAD>\n<BODY>\n<H1>", conf.bbs_name, "</H1><HR />");
|
||||||
if (header_tmp == NULL) {
|
if (header_tmp == NULL) {
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(header_tmp, "<HTML>\n<HEAD>\n<TITLE>%s</TITLE>\n</HEAD>\n<BODY>\n<H1>%s</H1><HR />", conf.bbs_name, conf.bbs_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header = str_replace(header_tmp, "@@WWW_URL@@", conf.www_url);
|
header = str_replace(header_tmp, "@@WWW_URL@@", conf.www_url);
|
||||||
@ -493,32 +418,14 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
|
|
||||||
snprintf(buffer, PATH_MAX, "%s/footer.tpl", conf.www_path);
|
snprintf(buffer, PATH_MAX, "%s/footer.tpl", conf.www_path);
|
||||||
|
|
||||||
footer_tmp = NULL;
|
footer_tmp = file2str(buffer);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
|
||||||
footer_tmp = (char *)malloc(s.st_size + 1);
|
|
||||||
if (footer_tmp == NULL) {
|
|
||||||
free(header);
|
|
||||||
return MHD_NO;
|
|
||||||
}
|
|
||||||
memset(footer_tmp, 0, s.st_size + 1);
|
|
||||||
fptr = fopen(buffer, "r");
|
|
||||||
if (fptr) {
|
|
||||||
fread(footer_tmp, s.st_size, 1, fptr);
|
|
||||||
fclose(fptr);
|
|
||||||
} else {
|
|
||||||
free(footer_tmp);
|
|
||||||
footer_tmp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (footer_tmp == NULL) {
|
if (footer_tmp == NULL) {
|
||||||
footer_tmp = (char *)malloc(43);
|
footer_tmp = strdup("<HR />Powered by Magicka BBS</BODY></HTML>");
|
||||||
if (footer_tmp == NULL) {
|
if (footer_tmp == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(footer_tmp, "<HR />Powered by Magicka BBS</BODY></HTML>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
footer = str_replace(footer_tmp, "@@WWW_URL@@", conf.www_url);
|
footer = str_replace(footer_tmp, "@@WWW_URL@@", conf.www_url);
|
||||||
@ -529,42 +436,21 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
|
|
||||||
snprintf(buffer, PATH_MAX, "%s/index.tpl", conf.www_path);
|
snprintf(buffer, PATH_MAX, "%s/index.tpl", conf.www_path);
|
||||||
|
|
||||||
page_tmp = NULL;
|
page_tmp = file2str(buffer);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
|
||||||
page_tmp = (char *)malloc(s.st_size + 1);
|
|
||||||
if (page_tmp == NULL) {
|
|
||||||
free(header);
|
|
||||||
free(footer);
|
|
||||||
return MHD_NO;
|
|
||||||
}
|
|
||||||
memset(page_tmp, 0, s.st_size + 1);
|
|
||||||
fptr = fopen(buffer, "r");
|
|
||||||
if (fptr) {
|
|
||||||
fread(page_tmp, s.st_size, 1, fptr);
|
|
||||||
fclose(fptr);
|
|
||||||
} else {
|
|
||||||
free(page_tmp);
|
|
||||||
page_tmp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
page_tmp = (char *)malloc(16);
|
page_tmp = strdup("Missing Content");
|
||||||
if (page_tmp == NULL) {
|
if (page_tmp == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page_tmp, "Missing Content");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
page = str_replace(page_tmp, "@@WWW_URL@@", conf.www_url);
|
||||||
free(page_tmp);
|
free(page_tmp);
|
||||||
|
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strcasecmp(url, "/last10/") == 0 || strcasecmp(url, "/last10") == 0) {
|
} else if (strcasecmp(url, "/last10/") == 0 || strcasecmp(url, "/last10") == 0) {
|
||||||
page = www_last10();
|
page = www_last10();
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
@ -572,9 +458,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strcasecmp(url, "/blog") == 0 || strcasecmp(url, "/blog/") == 0) {
|
} else if (strcasecmp(url, "/blog") == 0 || strcasecmp(url, "/blog/") == 0) {
|
||||||
page = www_blog();
|
page = www_blog();
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
@ -582,9 +466,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strcasecmp(url, "/email/") == 0 || strcasecmp(url, "/email") == 0) {
|
} else if (strcasecmp(url, "/email/") == 0 || strcasecmp(url, "/email") == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -600,9 +482,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strcasecmp(url, "/email/new") == 0) {
|
} else if (strcasecmp(url, "/email/new") == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -618,9 +498,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/email/delete/", 14) == 0) {
|
} else if (strncasecmp(url, "/email/delete/", 14) == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -632,30 +510,26 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
}
|
}
|
||||||
email = strtol(&url[14], &endptr, 10);
|
email = strtol(&url[14], &endptr, 10);
|
||||||
if (email == -1 || !www_email_delete(con_inf->user, email)) {
|
if (email == -1 || !www_email_delete(con_inf->user, email)) {
|
||||||
page = (char *)malloc(31);
|
page = strdup("<h1>Error Deleting Email.</h1>");
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page, "<h1>Error Deleting Email.</h1>");
|
|
||||||
} else {
|
} else {
|
||||||
page = (char *)malloc(24);
|
page = strdup("<h1>Email Deleted!</h1>");
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page, "<h1>Email Deleted!</h1>");
|
|
||||||
}
|
}
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/email/", 7) == 0) {
|
} else if (strncasecmp(url, "/email/", 7) == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -677,9 +551,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strcasecmp(url, "/msgs/") == 0 || strcasecmp(url, "/msgs") == 0) {
|
} else if (strcasecmp(url, "/msgs/") == 0 || strcasecmp(url, "/msgs") == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -695,9 +567,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/msgs/flag/", 11) == 0) {
|
} else if (strncasecmp(url, "/msgs/flag/", 11) == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -787,9 +657,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/msgs/", 6) == 0) {
|
} else if (strncasecmp(url, "/msgs/", 6) == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -851,9 +719,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/static/", 8) == 0) {
|
} else if (strncasecmp(url, "/static/", 8) == 0) {
|
||||||
// sanatize path
|
// sanatize path
|
||||||
if (strstr(url, "/..") != NULL) {
|
if (strstr(url, "/..") != NULL) {
|
||||||
@ -885,8 +751,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
if (stat(buffer, &s) == 0 && S_ISREG(s.st_mode)) {
|
if (stat(buffer, &s) == 0 && S_ISREG(s.st_mode)) {
|
||||||
fno = open(buffer, O_RDONLY);
|
fno = open(buffer, O_RDONLY);
|
||||||
if (fno != -1) {
|
if (fno != -1) {
|
||||||
|
//static_buffer = (char *)malloz(s.st_size + 1);
|
||||||
//static_buffer = (char *)malloc(s.st_size + 1);
|
|
||||||
//read(fno, static_buffer, s.st_size);
|
//read(fno, static_buffer, s.st_size);
|
||||||
response = MHD_create_response_from_fd(s.st_size, fno);
|
response = MHD_create_response_from_fd(s.st_size, fno);
|
||||||
//response = MHD_create_response_from_buffer (s.st_size, (void*) static_buffer, MHD_RESPMEM_MUST_FREE);
|
//response = MHD_create_response_from_buffer (s.st_size, (void*) static_buffer, MHD_RESPMEM_MUST_FREE);
|
||||||
@ -918,8 +783,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
}
|
}
|
||||||
} else if (strcasecmp(url, "/files/areas/") == 0 || strcasecmp(url, "/files/areas") == 0) {
|
} else if (strcasecmp(url, "/files/areas/") == 0 || strcasecmp(url, "/files/areas") == 0) {
|
||||||
page = www_files_areas();
|
page = www_files_areas();
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/files/areas/", 13) == 0) {
|
} else if (strncasecmp(url, "/files/areas/", 13) == 0) {
|
||||||
file_dir = -1;
|
file_dir = -1;
|
||||||
file_sub = -1;
|
file_sub = -1;
|
||||||
@ -1021,9 +885,7 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
free(footer);
|
free(footer);
|
||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
} else if (strncasecmp(url, "/files/", 7) == 0) {
|
} else if (strncasecmp(url, "/files/", 7) == 0) {
|
||||||
filename = www_decode_hash(&url[7]);
|
filename = www_decode_hash(&url[7]);
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
@ -1116,26 +978,21 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!www_send_email(con_inf->user, to, subj, body)) {
|
if (!www_send_email(con_inf->user, to, subj, body)) {
|
||||||
page = (char *)malloc(50);
|
page = strdup("<h1>Error Sending Email (Check User Exists?)</h1>");
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page, "<h1>Error Sending Email (Check User Exists?)</h1>");
|
|
||||||
} else {
|
} else {
|
||||||
page = (char *)malloc(21);
|
page = strdup("<h1>Email Sent!</h1>");
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page, "<h1>Email Sent!</h1>");
|
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
|
|
||||||
} else if (strcasecmp(url, "/msgs/") == 0 || strcasecmp(url, "/msgs") == 0) {
|
} else if (strcasecmp(url, "/msgs/") == 0 || strcasecmp(url, "/msgs") == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
|
||||||
@ -1185,26 +1042,21 @@ int www_handler(void *cls, struct MHD_Connection *connection, const char *url, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!www_send_msg(con_inf->user, to, subj, conference, area, replyid, body)) {
|
if (!www_send_msg(con_inf->user, to, subj, conference, area, replyid, body)) {
|
||||||
page = (char *)malloc(31);
|
page = strdup("<h1>Error Sending Message</h1>");
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page, "<h1>Error Sending Message</h1>");
|
|
||||||
} else {
|
} else {
|
||||||
page = (char *)malloc(23);
|
page = strdup("<h1>Message Sent!</h1>");
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
sprintf(page, "<h1>Message Sent!</h1>");
|
|
||||||
}
|
}
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = str3dup(header, page, footer);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
free(header);
|
free(header);
|
||||||
free(footer);
|
free(footer);
|
||||||
|
@ -22,10 +22,9 @@ char *www_blog() {
|
|||||||
char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???"};
|
char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???"};
|
||||||
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???"};
|
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???"};
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>System Blog</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>System Blog</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -117,4 +116,4 @@ char *www_blog() {
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -91,8 +91,7 @@ int www_send_email(struct user_record *user, char *recipient, char *subject, cha
|
|||||||
|
|
||||||
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s \r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, conf.default_tagline);
|
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s \r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, conf.default_tagline);
|
||||||
|
|
||||||
body = (char *)malloc(strlen(ibody) + strlen(buffer) + 1);
|
body = (char *)malloz(strlen(ibody) + strlen(buffer) + 1);
|
||||||
memset(body, 0, strlen(ibody) + strlen(buffer) + 1);
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
for (i = 0; i < strlen(ibody); i++) {
|
for (i = 0; i < strlen(ibody); i++) {
|
||||||
if (ibody[i] != '\n') {
|
if (ibody[i] != '\n') {
|
||||||
@ -147,10 +146,9 @@ char *www_new_email() {
|
|||||||
int len;
|
int len;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>New Email</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>New Email</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -240,10 +238,9 @@ char *www_email_display(struct user_record *user, int email) {
|
|||||||
|
|
||||||
char *update_seen_sql = "UPDATE email SET seen=1 WHERE id=?";
|
char *update_seen_sql = "UPDATE email SET seen=1 WHERE id=?";
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "%s/email.sq3", conf.bbs_path);
|
sprintf(buffer, "%s/email.sq3", conf.bbs_path);
|
||||||
|
|
||||||
@ -545,10 +542,9 @@ char *www_email_summary(struct user_record *user) {
|
|||||||
"date INTEGER,"
|
"date INTEGER,"
|
||||||
"seen INTEGER);";
|
"seen INTEGER);";
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>Your Email</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>Your Email</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
@ -12,7 +12,7 @@ extern struct user_record *gUser;
|
|||||||
extern char *aha(char *input);
|
extern char *aha(char *input);
|
||||||
|
|
||||||
static char *www_decode(char *clean_url) {
|
static char *www_decode(char *clean_url) {
|
||||||
char *url = (char *)malloc(strlen(clean_url) + 1);
|
char *url = (char *)malloz(strlen(clean_url) + 1);
|
||||||
int i;
|
int i;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@ -37,7 +37,7 @@ static char *www_decode(char *clean_url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *www_encode(char *url) {
|
static char *www_encode(char *url) {
|
||||||
char *clean_url = (char *)malloc(strlen(url) * 3 + 1);
|
char *clean_url = (char *)malloz(strlen(url) * 3 + 1);
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
@ -257,9 +257,7 @@ char *www_create_link(int dir, int sub, int fid) {
|
|||||||
|
|
||||||
sizereq = hashids_estimate_encoded_size_v(hashids, 4, (unsigned long long)gUser->id, (unsigned long long)dir, (unsigned long long)sub, (unsigned long long)fid);
|
sizereq = hashids_estimate_encoded_size_v(hashids, 4, (unsigned long long)gUser->id, (unsigned long long)dir, (unsigned long long)sub, (unsigned long long)fid);
|
||||||
|
|
||||||
hashid = (char *)malloc(sizereq + 1);
|
hashid = (char *)malloz(sizereq + 1);
|
||||||
|
|
||||||
memset(hashid, 0, sizereq + 1);
|
|
||||||
|
|
||||||
if (hashids_encode_v(hashids, hashid, 4, (unsigned long long)gUser->id, (unsigned long long)dir, (unsigned long long)sub, (unsigned long long)fid) == 0) {
|
if (hashids_encode_v(hashids, hashid, 4, (unsigned long long)gUser->id, (unsigned long long)dir, (unsigned long long)sub, (unsigned long long)fid) == 0) {
|
||||||
hashids_free(hashids);
|
hashids_free(hashids);
|
||||||
@ -298,10 +296,9 @@ char *www_files_display_listing(int dir, int sub) {
|
|||||||
int i;
|
int i;
|
||||||
char *clean_url;
|
char *clean_url;
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
snprintf(buffer, 4096, "<div class=\"content-header\"><h2>Files: %s - %s</h2></div>\n", conf.file_directories[dir]->name, conf.file_directories[dir]->file_subs[sub]->name);
|
snprintf(buffer, 4096, "<div class=\"content-header\"><h2>Files: %s - %s</h2></div>\n", conf.file_directories[dir]->name, conf.file_directories[dir]->file_subs[sub]->name);
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -428,10 +425,9 @@ char *www_files_areas() {
|
|||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>File Directories</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>File Directories</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -486,7 +482,7 @@ char *www_files_get_from_area(int dir, int sub, char *clean_file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filenamelike = (char *)malloc(strlen(file) + 3 + extra);
|
filenamelike = (char *)malloz(strlen(file) + 3 + extra);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
filenamelike[i++] = '%';
|
filenamelike[i++] = '%';
|
||||||
|
@ -31,10 +31,9 @@ char *www_last10() {
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>Last 10 Callers</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>Last 10 Callers</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
@ -30,8 +30,7 @@ char *www_sanitize(char *inp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (char *)malloc(len + 1);
|
result = (char *)malloz(len + 1);
|
||||||
memset(result, 0, len + 1);
|
|
||||||
len = 0;
|
len = 0;
|
||||||
for (i = 0; i < strlen(inp); i++) {
|
for (i = 0; i < strlen(inp); i++) {
|
||||||
if (inp[i] == '<') {
|
if (inp[i] == '<') {
|
||||||
@ -65,10 +64,9 @@ char *www_msgs_arealist(struct user_record *user) {
|
|||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>Message Conferences</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>Message Conferences</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -129,10 +127,9 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
|
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>%s - %s</h2></div>\n", conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
sprintf(buffer, "<div class=\"content-header\"><h2>%s - %s</h2></div>\n", conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -326,39 +323,19 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
|
|
||||||
for (z = 0; z < jsp->NumFields; z++) {
|
for (z = 0; z < jsp->NumFields; z++) {
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
||||||
subject = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
subject = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memset(subject, 0, jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
||||||
memcpy(subject, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
from = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
}
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
to = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
from = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
|
||||||
memset(from, 0, jsp->Fields[z]->DatLen + 1);
|
daddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memcpy(from, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
|
||||||
}
|
oaddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
||||||
to = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
msgid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
memset(to, 0, jsp->Fields[z]->DatLen + 1);
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
||||||
memcpy(to, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
replyid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
|
|
||||||
daddress = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(daddress, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(daddress, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
|
|
||||||
oaddress = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(oaddress, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(oaddress, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
|
||||||
msgid = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(msgid, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(msgid, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
|
||||||
replyid = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
|
||||||
memset(replyid, 0, jsp->Fields[z]->DatLen + 1);
|
|
||||||
memcpy(replyid, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JAM_DelSubPacket(jsp);
|
JAM_DelSubPacket(jsp);
|
||||||
@ -407,8 +384,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body = (char *)malloc(jmh.TxtLen + 1);
|
body = (char *)malloz(jmh.TxtLen + 1);
|
||||||
memset(body, 0, jmh.TxtLen + 1);
|
|
||||||
|
|
||||||
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
|
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
|
||||||
|
|
||||||
@ -427,10 +403,9 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
JAM_CloseMB(jb);
|
JAM_CloseMB(jb);
|
||||||
free(jb);
|
free(jb);
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><a href=\"%smsgs/%d/%d\"><h2>%s - %s</h2></a></div>\n", conf.www_url, conference, area, conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
sprintf(buffer, "<div class=\"content-header\"><a href=\"%smsgs/%d/%d\"><h2>%s - %s</h2></a></div>\n", conf.www_url, conference, area, conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
@ -542,7 +517,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
strcat(page, buffer);
|
strcat(page, buffer);
|
||||||
len += strlen(buffer);
|
len += strlen(buffer);
|
||||||
|
|
||||||
aha_text = (char *)malloc(jmh.TxtLen + 1);
|
aha_text = (char *)malloz(jmh.TxtLen + 1);
|
||||||
|
|
||||||
memcpy(aha_text, body, jmh.TxtLen);
|
memcpy(aha_text, body, jmh.TxtLen);
|
||||||
aha_text[jmh.TxtLen] = '\0';
|
aha_text[jmh.TxtLen] = '\0';
|
||||||
@ -647,7 +622,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
strcat(page, buffer);
|
strcat(page, buffer);
|
||||||
len += strlen(buffer);
|
len += strlen(buffer);
|
||||||
|
|
||||||
replybody = (char *)malloc(strlen(body) + 1);
|
replybody = (char *)malloz(strlen(body) + 1);
|
||||||
|
|
||||||
l2 = 0;
|
l2 = 0;
|
||||||
for (l1 = 0; l1 < strlen(body); l1++) {
|
for (l1 = 0; l1 < strlen(body); l1++) {
|
||||||
@ -813,10 +788,7 @@ static char *www_wordwrap(char *content, int cutoff) {
|
|||||||
at = 0;
|
at = 0;
|
||||||
|
|
||||||
len = strlen(content);
|
len = strlen(content);
|
||||||
ret = (char *)malloc(len + 1);
|
ret = (char *)malloz(len + 1);
|
||||||
if (ret == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
line_count = 0;
|
line_count = 0;
|
||||||
quote_line = 0;
|
quote_line = 0;
|
||||||
@ -889,7 +861,6 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
|||||||
char *body2;
|
char *body2;
|
||||||
char *tagline;
|
char *tagline;
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
int pos;
|
|
||||||
char *body3;
|
char *body3;
|
||||||
|
|
||||||
iconv_t ic;
|
iconv_t ic;
|
||||||
@ -1060,7 +1031,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
|||||||
free(jb);
|
free(jb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
body3 = (char *)malloc(strlen(body2) + 2 + strlen(buffer));
|
body3 = str2dup(body2, buffer);
|
||||||
if (body3 == NULL) {
|
if (body3 == NULL) {
|
||||||
free(body2);
|
free(body2);
|
||||||
JAM_UnlockMB(jb);
|
JAM_UnlockMB(jb);
|
||||||
@ -1070,12 +1041,8 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(body3, 0, strlen(body2) + 2 + strlen(buffer));
|
|
||||||
pos = 0;
|
|
||||||
sprintf(body3, "%s%s", body2, buffer);
|
|
||||||
|
|
||||||
free(body2);
|
free(body2);
|
||||||
body2 = (char *)malloc(strlen(body3) + 1);
|
body2 = (char *)malloz(strlen(body3) + 1);
|
||||||
|
|
||||||
ic = iconv_open("CP437", "UTF-8");
|
ic = iconv_open("CP437", "UTF-8");
|
||||||
|
|
||||||
@ -1123,10 +1090,9 @@ char *www_new_msg(struct user_record *user, int conference, int area) {
|
|||||||
int len;
|
int len;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
|
||||||
page = (char *)malloc(4096);
|
page = (char *)malloz(4096);
|
||||||
max_len = 4096;
|
max_len = 4096;
|
||||||
len = 0;
|
len = 0;
|
||||||
memset(page, 0, 4096);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>New Message</h2></div>\n");
|
sprintf(buffer, "<div class=\"content-header\"><h2>New Message</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
Reference in New Issue
Block a user