Bug 80378 - Mismatched length of ".pc" extension
Summary: Mismatched length of ".pc" extension
Status: RESOLVED FIXED
Alias: None
Product: pkg-config
Classification: Unclassified
Component: src (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pkg-config
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-23 07:32 UTC by Daniel Macks
Modified: 2014-11-12 15:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Use same token for malloc as for string construction (466 bytes, patch)
2014-06-23 07:32 UTC, Daniel Macks
Details | Splinter Review

Description Daniel Macks 2014-06-23 07:32:18 UTC
pkg.c scan_dir() has:

#define EXT_LEN 3
[...]
      int len = strlen (dent->d_name);
[...]
          char *pkgname = g_malloc (len - 2);
[...]
	  strncpy (pkgname, dent->d_name, len - EXT_LEN);
          pkgname[len-EXT_LEN] = '\0';

The goal is for pkgname to hold the name without the trailing ".pc" extension (according to the meaning of EXT_LEN as used in the ends_in_dotpc() function). But the malloc is hardcoded as 2. If the extension were to be changed, the number of characters being strncpy'ed would not match the size of the target buffer. Instead, the malloc should use the EXT_LEN token (adjusted for the trailing \0)
Comment 1 Daniel Macks 2014-06-23 07:32:57 UTC
Created attachment 101557 [details] [review]
Use same token for malloc as for string construction
Comment 2 Dan Nicholson 2014-11-12 15:50:06 UTC
Applied in 30437b4. Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.