signal(SIGINT, ok_bot_kill);
signal(SIGTERM, ok_bot_kill);
- char* construct = malloc(1025);
+ char* construct = malloc(4097);
if(ircpass != NULL && strlen(ircpass) > 0) {
sprintf(construct, "PASS :%s", ircpass);
int n = scandir(nntppath, &list, nodots, namesort);
if(n >= 0) {
int i;
+ uint64_t last = 0;
for(i = 0; i < n; i++) {
- if(!sendable) {
+ if(!sendable || strcmp(list[i]->d_name, ".") == 0 || strcmp(list[i]->d_name, "..") == 0) {
free(list[i]);
continue;
}
fprintf(stderr, "Could not read %s\n", construct);
}
}
+ last = atoi(list[i]->d_name) + 1;
free(list[i]);
}
- count = atoi(list[i - 1]->d_name) + 1;
+ count = last;
free(list);
}
if(sendable) {
fprintf(stderr, "Login successful\n");
sprintf(construct, "JOIN :%s", ircchan);
ircfw_socket_send_cmd(ok_sock, NULL, construct);
- } else if(res == 331 || res == 332) {
+ } else if(res == 366) {
sendable = true;
}
} else {
char* boundary = NULL;
char* buffer = malloc(s.st_size + 1);
buffer[s.st_size] = 0;
- FILE* f = fopen(path, "r");
+ FILE* f = fopen(path, "rb");
+ if(f == NULL){
+ free(buffer);
+ return 1;
+ }
fread(buffer, s.st_size, 1, f);
uint64_t i;
free(l);
free(buffer);
+ fclose(f);
if(boundary != NULL) free(boundary);
return 0;
} else {