MSVC++ disallows zero-length array in struct

This commit is contained in:
John Reiser 2011-11-23 13:05:00 -08:00
parent 31af22c2ff
commit f6ee8b9f04
2 changed files with 9 additions and 5 deletions

View File

@ -1711,13 +1711,15 @@ PackNetBSDElf32x86::generateElfHdr(
if (NHDR_NETBSD_TAG == np->type && 7== np->namesz if (NHDR_NETBSD_TAG == np->type && 7== np->namesz
&& NETBSD_DESCSZ == np->descsz && NETBSD_DESCSZ == np->descsz
&& 0==strcmp(ELF_NOTE_NETBSD_NAME, (char const *)&np->body)) { && 0==strcmp(ELF_NOTE_NETBSD_NAME,
/* &np->body */ (char const *)(1+ np))) {
np_NetBSD = np; np_NetBSD = np;
sz_NetBSD = k; sz_NetBSD = k;
} }
if (NHDR_PAX_TAG == np->type && 4== np->namesz if (NHDR_PAX_TAG == np->type && 4== np->namesz
&& PAX_DESCSZ==np->descsz && PAX_DESCSZ==np->descsz
&& 0==strcmp(ELF_NOTE_PAX_NAME, (char const *)&np->body)) { && 0==strcmp(ELF_NOTE_PAX_NAME,
/* &np->body */ (char const *)(1+ np))) {
np_PaX = np; np_PaX = np;
sz_PaX = k; sz_PaX = k;
} }
@ -1753,10 +1755,12 @@ PackNetBSDElf32x86::generateElfHdr(
set_te32(&phdr->p_flags, Elf32_Phdr::PF_R); set_te32(&phdr->p_flags, Elf32_Phdr::PF_R);
set_te32(&phdr->p_align, 4); set_te32(&phdr->p_align, 4);
unsigned bits = get_te32(&np_PaX->body[4]); unsigned bits = get_te32( /* &np_PaX->body[4] */
&(ACC_UNCONST_CAST(unsigned char *, (1+ np_PaX)))[4] );
bits &= ~PAX_MPROTECT; bits &= ~PAX_MPROTECT;
bits |= PAX_NOMPROTECT; bits |= PAX_NOMPROTECT;
set_te32(ACC_UNCONST_CAST(unsigned char *, &np_PaX->body[4]), bits); set_te32( /* &np_PaX->body[4] */
&(ACC_UNCONST_CAST(unsigned char *, (1+ np_PaX)))[4], bits);
sz_elf_hdrs += sz_PaX + sizeof(*phdr); sz_elf_hdrs += sz_PaX + sizeof(*phdr);
note_offset += sz_PaX; note_offset += sz_PaX;

View File

@ -190,7 +190,7 @@ protected:
unsigned namesz; unsigned namesz;
unsigned descsz; unsigned descsz;
unsigned type; unsigned type;
unsigned char body[0]; //unsigned char body[0];
}; };
static void compileTimeAssertions() { static void compileTimeAssertions() {