mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
Some code moving to avoid false positive leaks.
This commit is contained in:
parent
641d46cb3d
commit
78b3a30447
5 changed files with 39 additions and 23 deletions
|
@ -123,7 +123,7 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s
|
|||
response = http_signed_request(snac, "POST", inbox,
|
||||
NULL, j_msg, strlen(j_msg), &status, payload, p_size);
|
||||
|
||||
free(response);
|
||||
xs_free(response);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
|
|||
|
||||
/* if this message is public, ours will also be */
|
||||
if (is_msg_public(snac, p_msg) &&
|
||||
xs_list_in(to, (char *)public_address) == -1)
|
||||
xs_list_in(to, public_address) == -1)
|
||||
to = xs_list_append(to, public_address);
|
||||
}
|
||||
|
||||
|
|
6
data.c
6
data.c
|
@ -526,10 +526,10 @@ void _timeline_write(snac *snac, char *id, char *msg, char *parent, char *referr
|
|||
fclose(f);
|
||||
|
||||
xs *g_msg = xs_json_loads(j);
|
||||
d_char *meta = xs_dict_get(g_msg, "_snac");
|
||||
d_char *p = xs_dict_get(meta, "parent");
|
||||
char *meta = xs_dict_get(g_msg, "_snac");
|
||||
char *p = xs_dict_get(meta, "parent");
|
||||
|
||||
free(grampa);
|
||||
xs_free(grampa);
|
||||
grampa = xs_dup(p);
|
||||
}
|
||||
}
|
||||
|
|
29
httpd.c
29
httpd.c
|
@ -183,10 +183,8 @@ void httpd_connection(FILE *f)
|
|||
b_size = strlen(body);
|
||||
|
||||
/* if it was a HEAD, no body will be sent */
|
||||
if (strcmp(method, "HEAD") == 0) {
|
||||
free(body);
|
||||
body = NULL;
|
||||
}
|
||||
if (strcmp(method, "HEAD") == 0)
|
||||
body = xs_free(body);
|
||||
|
||||
xs_httpd_response(f, status, headers, body, b_size);
|
||||
|
||||
|
@ -194,7 +192,7 @@ void httpd_connection(FILE *f)
|
|||
|
||||
srv_archive("RECV", req, payload, p_size, status, headers, body, b_size);
|
||||
|
||||
free(body);
|
||||
xs_free(body);
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,18 +231,21 @@ static void *queue_thread(void *arg)
|
|||
srv_log(xs_fmt("queue thread start"));
|
||||
|
||||
while (srv_running) {
|
||||
xs *list = user_list();
|
||||
char *p, *uid;
|
||||
time_t t;
|
||||
|
||||
/* process queues for all users */
|
||||
p = list;
|
||||
while (xs_list_iter(&p, &uid)) {
|
||||
snac snac;
|
||||
{
|
||||
xs *list = user_list();
|
||||
char *p, *uid;
|
||||
|
||||
if (user_open(&snac, uid)) {
|
||||
process_queue(&snac);
|
||||
user_free(&snac);
|
||||
/* process queues for all users */
|
||||
p = list;
|
||||
while (xs_list_iter(&p, &uid)) {
|
||||
snac snac;
|
||||
|
||||
if (user_open(&snac, uid)) {
|
||||
process_queue(&snac);
|
||||
user_free(&snac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
xs.h
21
xs.h
|
@ -66,7 +66,7 @@ d_char *xs_list_append_m(d_char *list, const char *mem, int dsz);
|
|||
int xs_list_iter(char **list, char **value);
|
||||
int xs_list_len(char *list);
|
||||
char *xs_list_get(char *list, int num);
|
||||
int xs_list_in(char *list, char *val);
|
||||
int xs_list_in(char *list, const char *val);
|
||||
d_char *xs_join(char *list, const char *sep);
|
||||
d_char *xs_split_n(const char *str, const char *sep, int times);
|
||||
#define xs_split(str, sep) xs_split_n(str, sep, 0xfffffff)
|
||||
|
@ -96,12 +96,27 @@ void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char
|
|||
|
||||
#ifdef XS_DEBUG
|
||||
if (ndata != ptr) {
|
||||
int n;
|
||||
FILE *f = fopen("xs_memory.out", "a");
|
||||
|
||||
if (ptr != NULL)
|
||||
fprintf(f, "%p r\n", ptr);
|
||||
|
||||
fprintf(f, "%p a %ld %s %d %s\n", ndata, size, file, line, func);
|
||||
fprintf(f, "%p a %ld %s:%d: %s", ndata, size, file, line, func);
|
||||
|
||||
if (ptr != NULL) {
|
||||
fprintf(f, " [");
|
||||
for (n = 0; n < 32 && ndata[n]; n++) {
|
||||
if (ndata[n] >= 32 && ndata[n] <= 127)
|
||||
fprintf(f, "%c", ndata[n]);
|
||||
else
|
||||
fprintf(f, "\\%02x", (unsigned char)ndata[n]);
|
||||
}
|
||||
fprintf(f, "]");
|
||||
}
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
#endif
|
||||
|
@ -531,7 +546,7 @@ char *xs_list_get(char *list, int num)
|
|||
}
|
||||
|
||||
|
||||
int xs_list_in(char *list, char *val)
|
||||
int xs_list_in(char *list, const char *val)
|
||||
/* returns the position of val in list or -1 */
|
||||
{
|
||||
int n = 0;
|
||||
|
|
|
@ -1 +1 @@
|
|||
/* 286f556255aa224a72b778c44b837b75170becf5 */
|
||||
/* 870b15e48a153ac601046ac2dc72dd8ccb0c77a4 */
|
||||
|
|
Loading…
Reference in a new issue