fix for www hashes on rpi
This commit is contained in:
parent
b9dbf0f21f
commit
ff35d9bec9
@ -7,6 +7,7 @@
|
|||||||
#include "bbs.h"
|
#include "bbs.h"
|
||||||
#include "../deps/hashids/hashids.h"
|
#include "../deps/hashids/hashids.h"
|
||||||
|
|
||||||
|
|
||||||
extern struct bbs_config conf;
|
extern struct bbs_config conf;
|
||||||
extern struct user_record *gUser;
|
extern struct user_record *gUser;
|
||||||
extern char * aha(char *input);
|
extern char * aha(char *input);
|
||||||
@ -192,7 +193,7 @@ void www_add_hash_to_db(char *hash, time_t expiry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *www_decode_hash(char *hash) {
|
char *www_decode_hash(char *hash) {
|
||||||
long long unsigned numbers[4];
|
unsigned long long numbers[4];
|
||||||
int dir, sub, fid, uid;
|
int dir, sub, fid, uid;
|
||||||
hashids_t *hashids = hashids_init(conf.bbs_name);
|
hashids_t *hashids = hashids_init(conf.bbs_name);
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
@ -218,7 +219,7 @@ char *www_decode_hash(char *hash) {
|
|||||||
fid = (int)numbers[3];
|
fid = (int)numbers[3];
|
||||||
|
|
||||||
if (dir >= conf.file_directory_count || sub >= conf.file_directories[dir]->file_sub_count) {
|
if (dir >= conf.file_directory_count || sub >= conf.file_directories[dir]->file_sub_count) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get filename from database
|
// get filename from database
|
||||||
@ -255,13 +256,13 @@ char *www_create_link(int dir, int sub, int fid) {
|
|||||||
|
|
||||||
hashids_t *hashids = hashids_init(conf.bbs_name);
|
hashids_t *hashids = hashids_init(conf.bbs_name);
|
||||||
|
|
||||||
sizereq = hashids_estimate_encoded_size_v(hashids, 4, gUser->id, dir, sub, 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 *)malloc(sizereq + 1);
|
||||||
|
|
||||||
memset(hashid, 0, sizereq + 1);
|
memset(hashid, 0, sizereq + 1);
|
||||||
|
|
||||||
if (hashids_encode_v(hashids, hashid, 4, gUser->id, dir, sub, 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);
|
||||||
free(hashid);
|
free(hashid);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user