commit 05a0d9b6bf500a7b2955c4299a1912eb302ce40b
Author: Alexander Rogachev <[email protected]>
Date:   Mon Jul 4 22:51:37 2022 +0300

    [st][patch][ligatures] fix potential buffer overflow in shaping code

diff --git 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-20210824-0.8.4.diff 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-20210824-0.8.4.diff
index 0898447a..921e0f6f 100644
--- a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-20210824-0.8.4.diff
+++ b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-20210824-0.8.4.diff
@@ -45,7 +45,7 @@ new file mode 100644
 index 0000000..6389e95
 --- /dev/null
 +++ b/hb.c
-@@ -0,0 +1,145 @@
+@@ -0,0 +1,146 @@
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <math.h>
@@ -69,11 +69,12 @@ index 0000000..6389e95
 +static int hbfontslen = 0;
 +static HbFontMatch *hbfontcache = NULL;
 +
-+/* 
-+ * Replace 0 with a list of font features, wrapped in FEATURE macro, e.g. 
++/*
++ * Poplulate the array with a list of font features, wrapped in FEATURE macro,
++ * e. g.
 + * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
 + */
-+hb_feature_t features[] = { 0 };
++hb_feature_t features[] = { };
 +
 +void
 +hbunloadfonts()
@@ -177,7 +178,7 @@ index 0000000..6389e95
 +      }
 +
 +      /* Shape the segment. */
-+      hb_shape(font, buffer, features, sizeof(features));
++      hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
 +
 +      /* Get new glyph info. */
 +      hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
diff --git 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-20210824-0.8.4.diff
 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-20210824-0.8.4.diff
index 1c9f1d4c..fbf36977 100644
--- 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-20210824-0.8.4.diff
+++ 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-20210824-0.8.4.diff
@@ -45,7 +45,7 @@ new file mode 100644
 index 0000000..f9c4f76
 --- /dev/null
 +++ b/hb.c
-@@ -0,0 +1,144 @@
+@@ -0,0 +1,145 @@
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <math.h>
@@ -69,10 +69,11 @@ index 0000000..f9c4f76
 +static HbFontMatch *hbfontcache = NULL;
 +
 +/*
-+ * Replace 0 with a list of font features, wrapped in FEATURE macro, e.g.
++ * Poplulate the array with a list of font features, wrapped in FEATURE macro,
++ * e. g.
 + * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
 + */
-+hb_feature_t features[] = { 0 };
++hb_feature_t features[] = { };
 +
 +void
 +hbunloadfonts()
@@ -176,7 +177,7 @@ index 0000000..f9c4f76
 +      }
 +
 +      /* Shape the segment. */
-+      hb_shape(font, buffer, features, sizeof(features));
++      hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
 +
 +      /* Get new glyph info. */
 +      hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
diff --git 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-scrollback-20210824-0.8.4.diff
 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-scrollback-20210824-0.8.4.diff
index 0db9356e..34122ae3 100644
--- 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-scrollback-20210824-0.8.4.diff
+++ 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-alpha-scrollback-20210824-0.8.4.diff
@@ -45,7 +45,7 @@ new file mode 100644
 index 0000000..f9c4f76
 --- /dev/null
 +++ b/hb.c
-@@ -0,0 +1,144 @@
+@@ -0,0 +1,145 @@
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <math.h>
@@ -69,10 +69,11 @@ index 0000000..f9c4f76
 +static HbFontMatch *hbfontcache = NULL;
 +
 +/*
-+ * Replace 0 with a list of font features, wrapped in FEATURE macro, e.g.
++ * Poplulate the array with a list of font features, wrapped in FEATURE macro,
++ * e. g.
 + * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
 + */
-+hb_feature_t features[] = { 0 };
++hb_feature_t features[] = { };
 +
 +void
 +hbunloadfonts()
@@ -176,7 +177,7 @@ index 0000000..f9c4f76
 +      }
 +
 +      /* Shape the segment. */
-+      hb_shape(font, buffer, features, sizeof(features));
++      hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
 +
 +      /* Get new glyph info. */
 +      hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
diff --git 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-boxdraw-20210824-0.8.4.diff
 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-boxdraw-20210824-0.8.4.diff
index 5f3fa1de..bc145367 100644
--- 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-boxdraw-20210824-0.8.4.diff
+++ 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-boxdraw-20210824-0.8.4.diff
@@ -45,7 +45,7 @@ new file mode 100644
 index 0000000..a47300e
 --- /dev/null
 +++ b/hb.c
-@@ -0,0 +1,148 @@
+@@ -0,0 +1,149 @@
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <math.h>
@@ -69,10 +69,11 @@ index 0000000..a47300e
 +static HbFontMatch *hbfontcache = NULL;
 +
 +/*
-+ * Replace 0 with a list of font features, wrapped in FEATURE macro, e.g.
++ * Poplulate the array with a list of font features, wrapped in FEATURE macro,
++ * e. g.
 + * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
 + */
-+hb_feature_t features[] = { 0 };
++hb_feature_t features[] = { };
 +
 +void
 +hbunloadfonts()
@@ -180,7 +181,7 @@ index 0000000..a47300e
 +      }
 +
 +      /* Shape the segment. */
-+      hb_shape(font, buffer, features, sizeof(features));
++      hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
 +
 +      /* Get new glyph info. */
 +      hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
diff --git 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-scrollback-20210824-0.8.4.diff
 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-scrollback-20210824-0.8.4.diff
index 94e842ae..6805e3ee 100644
--- 
a/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-scrollback-20210824-0.8.4.diff
+++ 
b/st.suckless.org/patches/ligatures/0.8.4/st-ligatures-scrollback-20210824-0.8.4.diff
@@ -45,7 +45,7 @@ new file mode 100644
 index 0000000..f9c4f76
 --- /dev/null
 +++ b/hb.c
-@@ -0,0 +1,144 @@
+@@ -0,0 +1,145 @@
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <math.h>
@@ -69,10 +69,11 @@ index 0000000..f9c4f76
 +static HbFontMatch *hbfontcache = NULL;
 +
 +/*
-+ * Replace 0 with a list of font features, wrapped in FEATURE macro, e.g.
++ * Poplulate the array with a list of font features, wrapped in FEATURE macro,
++ * e. g.
 + * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
 + */
-+hb_feature_t features[] = { 0 };
++hb_feature_t features[] = { };
 +
 +void
 +hbunloadfonts()
@@ -176,7 +177,7 @@ index 0000000..f9c4f76
 +      }
 +
 +      /* Shape the segment. */
-+      hb_shape(font, buffer, features, sizeof(features));
++      hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
 +
 +      /* Get new glyph info. */
 +      hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);


Reply via email to