GNOME Bugzilla – Bug 765338
GLib.compute_hmac_for_data throws every time
Last modified: 2016-07-17 00:49:00 UTC
Raised already in the GJS mailing list, which is why I am writing this here now, no matter how you invoke the following: ``` GLib.compute_hmac_for_data( GLib.ChecksumType.SHA1, 'secret', 'secret'.length, 'the string', 'the string'.length ); ``` it will always throw an error such `Segmentation fault (core dumped)` or something like `GLib-CRITICAL **: g_compute_hmac_for_data: assertion 'length == 0 || data != NULL' failed null` Hints about the issue? Giovanni Campagna guessed: ``` there seems to be an annotation problem: argument data should be marked (array length=length). Right now for some reason it's inferred as guint8 (ie, the pointer is lost), which is very wrong. ```
Created attachment 326439 [details] [review] Fix annotations of g_compute_hmac_for_data
Created attachment 326440 [details] [review] Add g_compute_hmac_for_bytes() As an introspection-friendly GBytes variant of g_compute_hmac_for_data()
Review of attachment 326439 [details] [review]: LGTM
Review of attachment 326440 [details] [review]: Would be nice to have a test case even if it's trivial, just for the coverage aspect. LGTM otherwise. ::: glib/ghmac.c @@ +386,3 @@ + * The returned string should be freed with g_free() when done using it. + * + * Since: 2.30 2.50 ::: glib/ghmac.h @@ +74,3 @@ gssize length); +GLIB_AVAILABLE_IN_2_48 2.50 now I think. Which we need to add.
Attachment 326439 [details] pushed as a9e9bc7 - Fix annotations of g_compute_hmac_for_data Attachment 326440 [details] pushed as 183ed8a - Add g_compute_hmac_for_bytes()