Skip to content

Commit

Permalink
fix: time update stack smashing
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinFillon committed Jun 22, 2024
1 parent 65abfa9 commit b65ee5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions server/core/src/gui/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ static void update_clock(ai_t *ai, double nfreq)

void update_time(client_t *c, command_state_t *s)
{
int nfreq = 0;
long nfreq = 0;

if (str_toint((long *)&nfreq, s->args->data[1]) || nfreq < 0)
if (str_toint(&nfreq, s->args->data[1]) || nfreq < 0)
return send_invalid_args(c);
s->game->frequency = nfreq;
prepare_response_cat(&c->io, "sst %d\n", nfreq);
for (__auto_type i = 0ul; i < s->game->ais->size; i++) {
update_clock(s->game->ais->data[i], nfreq);
}
s->game->clock->frequency = nfreq;
s->game->global->frequency = nfreq;
}
2 changes: 1 addition & 1 deletion server/core/src/server/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int handle_buffer(client_t *c)
bool is_last_line = c->io.req->data[c->io.req->size - 1] == '\n' ||
c->io.req->data[c->io.req->size] == '\n';

logs(DEBUG, "Client %d has %d lines in buffer %d\n", c->fd, lines->size);
logs(DEBUG, "Client %d has %d lines in buffer\n", c->fd, lines->size);
if (lines->size == 0) {
vec_destroy_vector_str_t(lines);
return 0;
Expand Down

0 comments on commit b65ee5f

Please sign in to comment.