$ git clone https://socialnetwork.ion.nu/socialnetwork.git
commit 4c905f91264cd24d7964b5999e8835485b4ee83b
Author: Alicia <...>
Date: Sat May 13 21:58:37 2017 +0200
Fixed assumptions about ID sizes.
diff --git a/social.c b/social.c
index a416d9d..6c05f24 100644
--- a/social.c
+++ b/social.c
@@ -50,7 +50,7 @@ static void updateinfo(struct peer* peer, void* data, unsigned int len)
static void user_save(struct user* user)
{
if(!user->pubkey){return;}
- char path[strlen(social_prefix)+strlen("/users/0")+40];
+ char path[strlen(social_prefix)+strlen("/users/0")+ID_SIZE*2];
sprintf(path, "%s/users", social_prefix);
mkdir(path, 0700);
sprintf(path, "%s/users/"PEERFMT, social_prefix, PEERARG(user->id));
@@ -69,7 +69,7 @@ static void user_load(struct user* user)
// Load user data (only pubkey atm), but spare pubkey if it's already set
if(!user->pubkey)
{
- char path[strlen(social_prefix)+strlen("/users/0")+40];
+ char path[strlen(social_prefix)+strlen("/users/0")+ID_SIZE*2];
sprintf(path, "%s/users/"PEERFMT, social_prefix, PEERARG(user->id));
int f=open(path, O_RDONLY);
if(f>=0)
@@ -85,7 +85,7 @@ static void user_load(struct user* user)
}
}
// Load updates
- char path[strlen(social_prefix)+strlen("/updates/0")+40];
+ char path[strlen(social_prefix)+strlen("/updates/0")+ID_SIZE*2];
sprintf(path, "%s/updates/"PEERFMT, social_prefix, PEERARG(user->id));
int f=open(path, O_RDONLY);
if(f<0){return;}
diff --git a/update.c b/update.c
index 9d13a4e..aa69d92 100644
--- a/update.c
+++ b/update.c
@@ -109,7 +109,7 @@ void social_update_sign(struct update* update)
void social_update_save(struct user* user, struct update* update)
{
- char path[strlen(social_prefix)+strlen("/updates/0")+40];
+ char path[strlen(social_prefix)+strlen("/updates/0")+ID_SIZE*2];
sprintf(path, "%s/updates/"PEERFMT, social_prefix, PEERARG(user->id));
mkdirp(path);
int f=open(path, O_WRONLY|O_CREAT|O_APPEND, 0600);