After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 605104 - Off by one bug in unique_message_data_get_filename()
Off by one bug in unique_message_data_get_filename()
Status: RESOLVED FIXED
Product: libunique
Classification: Other
Component: core
master
Other Linux
: Normal normal
: ---
Assigned To: libunique-maint
libunique-maint
Depends on:
Blocks:
 
 
Reported: 2009-12-21 02:20 UTC by Rodney Lorrimar
Modified: 2010-05-08 11:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Suggested change to fix bug (1.19 KB, patch)
2009-12-21 02:20 UTC, Rodney Lorrimar
committed Details | Review
Test case (1.12 KB, text/plain)
2010-01-03 04:40 UTC, Rodney Lorrimar
  Details

Description Rodney Lorrimar 2009-12-21 02:20:16 UTC
Created attachment 150146 [details] [review]
Suggested change to fix bug

Hi,

Please see attached patch.


Cheers,

Rodney
Comment 1 Emmanuele Bassi (:ebassi) 2009-12-29 10:20:37 UTC
why do you feel there's an off-by-one bug?

set_filename() internally calls:

  set_data(filename, strlen(filename))

and set_data() does:

  message->data = g_new (unsigned char*, length + 1)
  message->length = length;
  memcpy (message->data, data, length);
  message->data[length] = 0;

which ends up terminating the string buffer.

can you please attach a minimal test case for set_filename() that fails for you? and could you please write a more descriptive bug report next time?

thanks for your time.
Comment 2 Rodney Lorrimar 2009-12-29 11:42:29 UTC
Hi,

Yes, message->data is correctly terminated. unique_message_data_get_filename() uses g_memdup() to copy it, but doesn't include the NULL. So that's what my patch fixes.

Please let me know if you still want the test case.

Cheers,

Rodney
Comment 3 Rodney Lorrimar 2010-01-03 04:40:06 UTC
Created attachment 150722 [details]
Test case

OK here is a test case.
Comment 4 Rodney Lorrimar 2010-04-20 02:01:14 UTC
Hi Emmanuele,

Did you get time to try the test case?

Cheers,

Rodney
Comment 5 Emmanuele Bassi (:ebassi) 2010-05-08 11:20:04 UTC
Pushed to master, will backport to the stable branch as well. Sorry for the delay in applying the patch.