mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 13:00:06 +00:00
(save_cache): Don't write beyond end of file_entries buffer. Duplicate last old cache entry if the count would be odd.
This commit is contained in:
parent
47ceb39de3
commit
062df96045
16
elf/cache.c
16
elf/cache.c
@ -305,6 +305,13 @@ save_cache (const char *cache_name)
|
|||||||
|
|
||||||
if (opt_format != 2)
|
if (opt_format != 2)
|
||||||
{
|
{
|
||||||
|
/* struct cache_file_new is 64-bit aligned on some arches while
|
||||||
|
only 32-bit aligned on other arches. Duplicate last old
|
||||||
|
cache entry so that new cache in ld.so.cache can be used by
|
||||||
|
both. */
|
||||||
|
if (opt_format != 0)
|
||||||
|
cache_entry_old_count = (cache_entry_old_count + 1) & ~1;
|
||||||
|
|
||||||
/* And the list of all entries in the old format. */
|
/* And the list of all entries in the old format. */
|
||||||
file_entries_size = sizeof (struct cache_file)
|
file_entries_size = sizeof (struct cache_file)
|
||||||
+ cache_entry_old_count * sizeof (struct file_entry);
|
+ cache_entry_old_count * sizeof (struct file_entry);
|
||||||
@ -351,7 +358,7 @@ save_cache (const char *cache_name)
|
|||||||
entry = entry->next, ++idx_new)
|
entry = entry->next, ++idx_new)
|
||||||
{
|
{
|
||||||
/* First the library. */
|
/* First the library. */
|
||||||
if (opt_format != 2)
|
if (opt_format != 2 && entry->hwcap == 0)
|
||||||
{
|
{
|
||||||
file_entries->libs[idx_old].flags = entry->flags;
|
file_entries->libs[idx_old].flags = entry->flags;
|
||||||
/* XXX: Actually we can optimize here and remove duplicates. */
|
/* XXX: Actually we can optimize here and remove duplicates. */
|
||||||
@ -374,7 +381,7 @@ save_cache (const char *cache_name)
|
|||||||
++str;
|
++str;
|
||||||
str_offset += len + 1;
|
str_offset += len + 1;
|
||||||
/* Then the path. */
|
/* Then the path. */
|
||||||
if (opt_format != 2)
|
if (opt_format != 2 && entry->hwcap == 0)
|
||||||
file_entries->libs[idx_old].value = str_offset + pad;
|
file_entries->libs[idx_old].value = str_offset + pad;
|
||||||
if (opt_format != 0)
|
if (opt_format != 0)
|
||||||
file_entries_new->libs[idx_new].value = str_offset;
|
file_entries_new->libs[idx_new].value = str_offset;
|
||||||
@ -388,6 +395,11 @@ save_cache (const char *cache_name)
|
|||||||
++idx_old;
|
++idx_old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Duplicate last old cache entry if needed. */
|
||||||
|
if (opt_format != 2
|
||||||
|
&& idx_old < cache_entry_old_count)
|
||||||
|
file_entries->libs[idx_old] = file_entries->libs[idx_old - 1];
|
||||||
|
|
||||||
/* Write out the cache. */
|
/* Write out the cache. */
|
||||||
|
|
||||||
/* Write cache first to a temporary file and rename it later. */
|
/* Write cache first to a temporary file and rename it later. */
|
||||||
|
@ -11,8 +11,8 @@ email "Djan_Sacre@skynet.be, pablo@mandrakesoft.com"
|
|||||||
address ""
|
address ""
|
||||||
tel ""
|
tel ""
|
||||||
fax ""
|
fax ""
|
||||||
language "wa"
|
language "Walloon"
|
||||||
territory "BE"
|
territory "Belgium"
|
||||||
revision "0.7"
|
revision "0.7"
|
||||||
date "2002-02-11"
|
date "2002-02-11"
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ contact "Pablo Saratxaga"
|
|||||||
email "pablo@mandrakesoft.com"
|
email "pablo@mandrakesoft.com"
|
||||||
tel ""
|
tel ""
|
||||||
fax ""
|
fax ""
|
||||||
language "yi"
|
language "Yiddish"
|
||||||
territory "US"
|
territory "USA"
|
||||||
revision "0.3"
|
revision "0.3"
|
||||||
date "2001-01-28"
|
date "2001-01-28"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user