Skip to content

Commit

Permalink
Merge tag 'urgent_fix_2023-03-18' of https://github.com/alviroiskanda…
Browse files Browse the repository at this point in the history
…r/GNUWeebBot2

Pull one urgent core fix from Alviro:

  "Fix get_sqe fail path.

   When gw_ring_get_sqe() fails, the subroutine tries to submit the pending
   SQEs but doesn't fill the @sqe variable after submission. Therefore,
   it's left as NULL, and the prep function will hit a NULL pointer
   dereference bug. Fix this by calling gw_ring_get_sqe() again after
   submission."

* tag 'urgent_fix_2023-03-18' of https://github.com/alviroiskandar/GNUWeebBot2:
  core/main: Fix get_sqe fail path

Link: https://lore.gnuweeb.org/gwml/20230318084646.3906201-1-alviro.iskandar@gnuweeb.org
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
  • Loading branch information
ammarfaizi2 committed Mar 18, 2023
2 parents 53f76b7 + d810938 commit 3cd2665
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/main.c
Expand Up @@ -20,8 +20,10 @@ static void arm_update_sqe(struct tg_bot_ctx *ctx)
struct gw_ring_sqe *sqe;

sqe = gw_ring_get_sqe(&ctx->ring);
if (unlikely(!sqe))
if (unlikely(!sqe)) {
gw_ring_submit(&ctx->ring);
sqe = gw_ring_get_sqe(&ctx->ring);
}

ctx->updates = NULL;
gw_ring_prep_tg_get_updates(sqe, &ctx->tctx, &ctx->updates,
Expand All @@ -34,8 +36,10 @@ static int prep_update_handle(struct tg_bot_ctx *ctx, struct tg_update *up)
struct gw_ring_sqe *sqe;

sqe = gw_ring_get_sqe(&ctx->ring);
if (unlikely(!sqe))
if (unlikely(!sqe)) {
gw_ring_submit(&ctx->ring);
sqe = gw_ring_get_sqe(&ctx->ring);
}

gw_ring_prep_tg_module_handle(sqe, ctx, up);
sqe->user_data = 0;
Expand Down

0 comments on commit 3cd2665

Please sign in to comment.