Bug 776

Summary: Inconsistent struct gconvcache_header
Product: glibc Reporter: H.J. Lu <hjl.tools>
Component: libcAssignee: GOTO Masanori <gotom>
Status: RESOLVED FIXED    
Severity: normal CC: glibc-bugs
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:
Bug Depends on:    
Bug Blocks: 724    

Description H.J. Lu 2005-03-02 01:21:32 UTC
In iconvconfig.h, there are

typedef uint16_t gidx_t;


struct gconvcache_header
{
  uint32_t magic;
  gidx_t string_offset;
  gidx_t hash_offset;
  gidx_t hash_size;
  gidx_t module_offset;
  gidx_t otherconv_offset;
};

But in iconvconfig.c, there are

/* Format of the output file.

   Offset   Length       Description
   0000     4            Magic header bytes
   0004     4            Offset of string table (stoff)
   0008     4            Offset of name hashing table (hoff)
   000C     4            Hashing table size (hsize)
   0010     4            Offset of module table (moff)
   0014     4            Offset of other conversion module table (ooff)

   stoff    ???          String table

The lengths of stoff, hoff, hsize, moff and ooff are 2 not 4.

Also compiler may put padding in struct gconvcache_header, which may not
be initialized. When write_output does

  iov[0].iov_base = &header;
  iov[0].iov_len = sizeof (struct gconvcache_header);
  total = iov[0].iov_len;

we may get different values in padding for different compilers.
Comment 1 Ulrich Drepper 2005-03-03 08:28:26 UTC
Fixed in CVS.
Comment 2 Sourceware Commits 2005-03-03 16:28:04 UTC
Subject: Bug 776

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	fedora-2_3-branch
Changes by:	jakub@sources.redhat.com	2005-03-03 16:27:44

Modified files:
	.              : ChangeLog 
	iconv          : iconvconfig.c 

Log message:
	[BZ #776]
	* iconv/iconvconfig.c: Fix comment for the output file.
	(write_output): Clear padding in header.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&only_with_tag=fedora-2_3-branch&r1=1.8782.2.67.2.4&r2=1.8782.2.67.2.5
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/iconv/iconvconfig.c.diff?cvsroot=glibc&only_with_tag=fedora-2_3-branch&r1=1.19.2.2.2.1&r2=1.19.2.2.2.2

Comment 3 Sourceware Commits 2005-04-06 00:38:04 UTC
Subject: Bug 776

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_3-branch
Changes by:	roland@sources.redhat.com	2005-04-06 00:37:53

Modified files:
	iconv          : iconvconfig.c 

Log message:
	2005-03-01  H.J. Lu  <hongjiu.lu@intel.com>
	
	[BZ #776]
	* iconv/iconvconfig.c: Fix comment for the output file.
	(write_output): Clear padding in header.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/iconv/iconvconfig.c.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.21.2.1&r2=1.21.2.2