0001-fix-null-pointer-dereference-in-yasm_expr_get_intnum.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. From 48ced849ed621a05cec4c04d4567323af3a76e81 Mon Sep 17 00:00:00 2001
  2. From: dataisland <dataisland@outlook.com>
  3. Date: Fri, 15 Sep 2023 18:20:49 +0000
  4. Subject: [PATCH] Fix null-pointer-dereference in yasm_expr_get_intnum
  5. Fixes the following CVE:
  6. - CVE-2021-33454: NULL pointer dereference in yasm_expr_get_intnum() in libyasm/expr.c
  7. For more info see:
  8. - https://nvd.nist.gov/vuln/detail/CVE-2021-33454
  9. - https://github.com/yasm/yasm/pull/244
  10. Upstream: https://github.com/yasm/yasm/pull/244
  11. Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
  12. ---
  13. libyasm/expr.c | 2 +-
  14. 1 file changed, 1 insertion(+), 1 deletion(-)
  15. diff --git a/libyasm/expr.c b/libyasm/expr.c
  16. index c2c868ede..6838eca56 100644
  17. --- a/libyasm/expr.c
  18. +++ b/libyasm/expr.c
  19. @@ -1260,7 +1260,7 @@ yasm_expr_get_intnum(yasm_expr **ep, int calc_bc_dist)
  20. {
  21. *ep = yasm_expr_simplify(*ep, calc_bc_dist);
  22. - if ((*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_INT)
  23. + if (*ep && (*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_INT)
  24. return (*ep)->terms[0].data.intn;
  25. else
  26. return (yasm_intnum *)NULL;