Also move some #pragma pack() to the proper position.
| ... | ... |
@@ -17613,6 +17613,82 @@ $as_echo "#define HAVE_ATTRIB_ALIGNED 1" >>confdefs.h |
| 17613 | 17613 |
|
| 17614 | 17614 |
fi |
| 17615 | 17615 |
|
| 17616 |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that structure packing works" >&5
|
|
| 17617 |
+$as_echo_n "checking that structure packing works... " >&6; } |
|
| 17618 |
+if test "${have_cv_struct_pack+set}" = set; then :
|
|
| 17619 |
+ $as_echo_n "(cached) " >&6 |
|
| 17620 |
+else |
|
| 17621 |
+ |
|
| 17622 |
+ if test "$cross_compiling" = yes; then : |
|
| 17623 |
+ have_cv_struct_pack=yes |
|
| 17624 |
+else |
|
| 17625 |
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
|
| 17626 |
+/* end confdefs.h. */ |
|
| 17627 |
+ |
|
| 17628 |
+#ifndef HAVE_ATTRIB_PACKED |
|
| 17629 |
+#define __attribute__(x) |
|
| 17630 |
+#endif |
|
| 17631 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 17632 |
+#pragma pack(1) /* has to be in column 1 ! */ |
|
| 17633 |
+#endif |
|
| 17634 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 17635 |
+#pragma pack 1 /* has to be in column 1 ! */ |
|
| 17636 |
+#endif |
|
| 17637 |
+ |
|
| 17638 |
+struct { char c __attribute__((packed)); long l __attribute__((packed)); } s;
|
|
| 17639 |
+ |
|
| 17640 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 17641 |
+#pragma pack() |
|
| 17642 |
+#endif |
|
| 17643 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 17644 |
+#pragma pack |
|
| 17645 |
+#endif |
|
| 17646 |
+ |
|
| 17647 |
+struct { char c; long l;} s2;
|
|
| 17648 |
+ |
|
| 17649 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 17650 |
+#pragma pack(1) /* has to be in column 1 ! */ |
|
| 17651 |
+#endif |
|
| 17652 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 17653 |
+#pragma pack 1 /* has to be in column 1 ! */ |
|
| 17654 |
+#endif |
|
| 17655 |
+ |
|
| 17656 |
+struct { char c; long l; } __attribute__((packed)) s3;
|
|
| 17657 |
+ |
|
| 17658 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 17659 |
+#pragma pack() |
|
| 17660 |
+#endif |
|
| 17661 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 17662 |
+#pragma pack |
|
| 17663 |
+#endif |
|
| 17664 |
+ |
|
| 17665 |
+ int main(int argc, char **argv) {
|
|
| 17666 |
+ if (sizeof(s)!=sizeof(s.c)+sizeof(s.l)) |
|
| 17667 |
+ return 1; |
|
| 17668 |
+ if (sizeof(s) != sizeof(s3)) |
|
| 17669 |
+ return 2; |
|
| 17670 |
+ return (sizeof(s2) >= sizeof(s)) ? 0 : 3; |
|
| 17671 |
+ } |
|
| 17672 |
+_ACEOF |
|
| 17673 |
+if ac_fn_c_try_run "$LINENO"; then : |
|
| 17674 |
+ have_cv_struct_pack=yes |
|
| 17675 |
+else |
|
| 17676 |
+ have_cv_struct_pack=no |
|
| 17677 |
+fi |
|
| 17678 |
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ |
|
| 17679 |
+ conftest.$ac_objext conftest.beam conftest.$ac_ext |
|
| 17680 |
+fi |
|
| 17681 |
+ |
|
| 17682 |
+ |
|
| 17683 |
+fi |
|
| 17684 |
+ |
|
| 17685 |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_cv_struct_pack" >&5
|
|
| 17686 |
+$as_echo "$have_cv_struct_pack" >&6; } |
|
| 17687 |
+ |
|
| 17688 |
+if test "$have_cv_struct_pack" = "no"; then |
|
| 17689 |
+ as_fn_error "Structure packing seems to be available, but is not working with this compiler" "$LINENO" 5 |
|
| 17690 |
+fi |
|
| 17691 |
+ |
|
| 17616 | 17692 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fd_set" >&5
|
| 17617 | 17693 |
$as_echo_n "checking for fd_set... " >&6; } |
| 17618 | 17694 |
cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
| ... | ... |
@@ -1396,6 +1396,64 @@ if test "$have_cv_attrib_aligned" = yes; then |
| 1396 | 1396 |
AC_DEFINE([HAVE_ATTRIB_ALIGNED], 1, [attrib aligned]) |
| 1397 | 1397 |
fi |
| 1398 | 1398 |
|
| 1399 |
+dnl Sanity check that struct packing works |
|
| 1400 |
+AC_MSG_CHECKING([that structure packing works]) |
|
| 1401 |
+AC_CACHE_VAL([have_cv_struct_pack],[ |
|
| 1402 |
+ AC_TRY_RUN([ |
|
| 1403 |
+#ifndef HAVE_ATTRIB_PACKED |
|
| 1404 |
+#define __attribute__(x) |
|
| 1405 |
+#endif |
|
| 1406 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 1407 |
+#pragma pack(1) /* has to be in column 1 ! */ |
|
| 1408 |
+#endif |
|
| 1409 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 1410 |
+#pragma pack 1 /* has to be in column 1 ! */ |
|
| 1411 |
+#endif |
|
| 1412 |
+ |
|
| 1413 |
+struct { char c __attribute__((packed)); long l __attribute__((packed)); } s;
|
|
| 1414 |
+ |
|
| 1415 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 1416 |
+#pragma pack() |
|
| 1417 |
+#endif |
|
| 1418 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 1419 |
+#pragma pack |
|
| 1420 |
+#endif |
|
| 1421 |
+ |
|
| 1422 |
+struct { char c; long l;} s2;
|
|
| 1423 |
+ |
|
| 1424 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 1425 |
+#pragma pack(1) /* has to be in column 1 ! */ |
|
| 1426 |
+#endif |
|
| 1427 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 1428 |
+#pragma pack 1 /* has to be in column 1 ! */ |
|
| 1429 |
+#endif |
|
| 1430 |
+ |
|
| 1431 |
+struct { char c; long l; } __attribute__((packed)) s3;
|
|
| 1432 |
+ |
|
| 1433 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 1434 |
+#pragma pack() |
|
| 1435 |
+#endif |
|
| 1436 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 1437 |
+#pragma pack |
|
| 1438 |
+#endif |
|
| 1439 |
+ |
|
| 1440 |
+ int main(int argc, char **argv) {
|
|
| 1441 |
+ if (sizeof(s)!=sizeof(s.c)+sizeof(s.l)) |
|
| 1442 |
+ return 1; |
|
| 1443 |
+ if (sizeof(s) != sizeof(s3)) |
|
| 1444 |
+ return 2; |
|
| 1445 |
+ return (sizeof(s2) >= sizeof(s)) ? 0 : 3; |
|
| 1446 |
+ }], |
|
| 1447 |
+ [have_cv_struct_pack=yes], |
|
| 1448 |
+ [have_cv_struct_pack=no], |
|
| 1449 |
+ [have_cv_struct_pack=yes]) |
|
| 1450 |
+]) |
|
| 1451 |
+AC_MSG_RESULT([$have_cv_struct_pack]) |
|
| 1452 |
+ |
|
| 1453 |
+if test "$have_cv_struct_pack" = "no"; then |
|
| 1454 |
+ AC_MSG_ERROR([Structure packing seems to be available, but is not working with this compiler]) |
|
| 1455 |
+fi |
|
| 1456 |
+ |
|
| 1399 | 1457 |
dnl Check if <sys/select.h> needs to be included for fd_set |
| 1400 | 1458 |
AC_MSG_CHECKING([for fd_set]) |
| 1401 | 1459 |
AC_HEADER_EGREP([fd_mask], [sys/select.h], [have_fd_set=yes]) |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* |
| 2 |
- * Copyright (C) 2007-2009 Sourcefire, Inc. |
|
| 2 |
+ * Copyright (C) 2007-2010 Sourcefire, Inc. |
|
| 3 | 3 |
* |
| 4 | 4 |
* Authors: Tomasz Kojm, Trog |
| 5 | 5 |
* |
| ... | ... |
@@ -259,6 +259,11 @@ int cl_init(unsigned int initoptions) |
| 259 | 259 |
struct timeval tv; |
| 260 | 260 |
unsigned int pid = (unsigned int) getpid(); |
| 261 | 261 |
|
| 262 |
+ if (sizeof(unrar_main_header_t) != UNRAR_MAIN_HEADER_TAG_LEN) {
|
|
| 263 |
+ cli_errmsg("Structure packing not working, expected %u bytes, got %u bytes\n",
|
|
| 264 |
+ sizeof(unrar_main_header_t), UNRAR_MAIN_HEADER_TAG_LEN); |
|
| 265 |
+ return CL_EARG; |
|
| 266 |
+ } |
|
| 262 | 267 |
/* put dlopen() stuff here, etc. */ |
| 263 | 268 |
if (lt_init() == 0) {
|
| 264 | 269 |
cli_rarload(); |
| ... | ... |
@@ -300,6 +300,15 @@ extern int have_rar; |
| 300 | 300 |
(((v) & 0x00ff000000000000ULL) >> 40) | \ |
| 301 | 301 |
(((v) & 0xff00000000000000ULL) >> 56)) |
| 302 | 302 |
|
| 303 |
+#ifndef HAVE_ATTRIB_PACKED |
|
| 304 |
+#define __attribute__(x) |
|
| 305 |
+#endif |
|
| 306 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 307 |
+#pragma pack(1) |
|
| 308 |
+#endif |
|
| 309 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 310 |
+#pragma pack 1 |
|
| 311 |
+#endif |
|
| 303 | 312 |
|
| 304 | 313 |
union unaligned_64 {
|
| 305 | 314 |
uint64_t una_u64; |
| ... | ... |
@@ -315,18 +324,6 @@ union unaligned_16 {
|
| 315 | 315 |
uint16_t una_u16; |
| 316 | 316 |
int16_t una_s16; |
| 317 | 317 |
} __attribute__((packed)); |
| 318 |
-#if WORDS_BIGENDIAN == 0 |
|
| 319 |
- |
|
| 320 |
-#ifndef HAVE_ATTRIB_PACKED |
|
| 321 |
-#define __attribute__(x) |
|
| 322 |
-#endif |
|
| 323 |
-#ifdef HAVE_PRAGMA_PACK |
|
| 324 |
-#pragma pack(1) |
|
| 325 |
-#endif |
|
| 326 |
-#ifdef HAVE_PRAGMA_PACK_HPPA |
|
| 327 |
-#pragma pack 1 |
|
| 328 |
-#endif |
|
| 329 |
- |
|
| 330 | 318 |
|
| 331 | 319 |
#ifdef HAVE_PRAGMA_PACK |
| 332 | 320 |
#pragma pack() |
| ... | ... |
@@ -334,6 +331,9 @@ union unaligned_16 {
|
| 334 | 334 |
#ifdef HAVE_PRAGMA_PACK_HPPA |
| 335 | 335 |
#pragma pack |
| 336 | 336 |
#endif |
| 337 |
+ |
|
| 338 |
+#if WORDS_BIGENDIAN == 0 |
|
| 339 |
+ |
|
| 337 | 340 |
/* Little endian */ |
| 338 | 341 |
#define le16_to_host(v) (v) |
| 339 | 342 |
#define le32_to_host(v) (v) |
| ... | ... |
@@ -59,6 +59,7 @@ typedef struct unrar_comment_header_tag |
| 59 | 59 |
uint16_t comm_crc __attribute__ ((packed)); |
| 60 | 60 |
} unrar_comment_header_t; |
| 61 | 61 |
|
| 62 |
+#define UNRAR_MAIN_HEADER_TAG_LEN 13 |
|
| 62 | 63 |
typedef struct unrar_main_header_tag |
| 63 | 64 |
{
|
| 64 | 65 |
uint16_t head_crc __attribute__ ((packed)); |
| ... | ... |
@@ -91,6 +92,14 @@ typedef struct unrar_file_header_tag |
| 91 | 91 |
off_t next_offset __attribute__ ((packed)); |
| 92 | 92 |
} unrar_fileheader_t; |
| 93 | 93 |
|
| 94 |
+#ifdef HAVE_PRAGMA_PACK |
|
| 95 |
+#pragma pack() |
|
| 96 |
+#endif |
|
| 97 |
+ |
|
| 98 |
+#ifdef HAVE_PRAGMA_PATCH_HPPA |
|
| 99 |
+#pragma pack |
|
| 100 |
+#endif |
|
| 101 |
+ |
|
| 94 | 102 |
typedef struct unrar_metadata_tag |
| 95 | 103 |
{
|
| 96 | 104 |
uint64_t pack_size; |
| ... | ... |
@@ -115,13 +124,6 @@ typedef struct unrar_state_tag {
|
| 115 | 115 |
char filename[1024]; |
| 116 | 116 |
} unrar_state_t; |
| 117 | 117 |
|
| 118 |
-#ifdef HAVE_PRAGMA_PACK |
|
| 119 |
-#pragma pack() |
|
| 120 |
-#endif |
|
| 121 |
- |
|
| 122 |
-#ifdef HAVE_PRAGMA_PATCH_HPPA |
|
| 123 |
-#pragma pack |
|
| 124 |
-#endif |
|
| 125 | 118 |
|
| 126 | 119 |
int unrar_open(int fd, const char *dirname, unrar_state_t *state); |
| 127 | 120 |
int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname); |