Changeset 73834


Ignore:
Timestamp:
Nov 26, 2010, 7:26:36 PM (9 years ago)
Author:
jmr@…
Message:

ctool: fix 64-bit build error (#20961) and warnings

Location:
trunk/dports/security/ctool
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/security/ctool/Portfile

    r69520 r73834  
    1818                        port:curl
    1919patchfiles              patch-Makefile \
    20                         patch-ctool.c
     20                        patch-ctool.c \
     21                        patch-safe_string.c
    2122use_configure           no
    2223build.env               CC=${configure.cc} \
  • trunk/dports/security/ctool/files/patch-ctool.c

    r56179 r73834  
    1 --- ctool.c.orig        2004-04-02 08:39:45.000000000 -0600
    2 +++ ctool.c     2009-08-25 00:10:15.000000000 -0500
    3 @@ -779,7 +779,7 @@
     1--- ctool.c.orig        2004-04-03 00:39:45.000000000 +1000
     2+++ ctool.c     2010-11-27 06:22:17.000000000 +1100
     3@@ -26,12 +26,14 @@
     4 
     5 #include <stdlib.h>
     6 #include <stdio.h>
     7+#include <string.h>
     8 #include <unistd.h>
     9 #include <fcntl.h>
     10 
     11 #include <sys/stat.h>
     12 #include <sys/types.h>
     13 #include <sys/errno.h>
     14+#include <sys/mman.h>
     15 #include <sys/time.h>
     16 #include <sys/param.h>
     17 
     18@@ -252,12 +254,10 @@ void process_file( const char *file_path
     19     struct load_command command;
     20     struct stat stats;
     21 
     22-    kern_return_t result;
     23-
     24     int fd;
     25     int length;
     26 
     27-    unsigned long size;
     28+    off_t size;
     29     unsigned long index;
     30     unsigned long remaining;
     31     unsigned long file_pos;
     32@@ -308,9 +308,13 @@ void process_file( const char *file_path
     33         fprintf( stderr, "...skipping zero length file.\n" );
     34         goto exit_gracefully;
     35     }
     36+    if( size > SIZE_T_MAX )
     37+    {
     38+        size = SIZE_T_MAX;
     39+    }
     40 
     41-    if( ( result = map_fd( (int)fd, (vm_offset_t)0, (vm_offset_t *)&addr_base,
     42-                           (boolean_t)TRUE, (vm_size_t)size) ) != KERN_SUCCESS )
     43+    if( ( addr_base = mmap( NULL, (size_t)size, PROT_READ, MAP_FILE|MAP_PRIVATE,
     44+                           (int)fd, (off_t)0) ) == MAP_FAILED )
     45     {
     46         fprintf( stderr, "unable to map file: %s\n", path );
     47         goto exit_gracefully;
     48@@ -405,13 +409,13 @@ print_hash:
     49 
     50     if( debug )
     51     {
     52-        int bytes_excluded = ( size - bytes_read );
     53+        size_t bytes_excluded = ( size - bytes_read );
     54 
     55-        fprintf( stdout, "file size: (%d) bytes.\n", size );
     56+        fprintf( stdout, "file size: (%llu) bytes.\n", size );
     57 
     58         if( has_prebinding )
     59         {
     60-            fprintf( stdout, "excluded a total of %d bytes from checksum.\n",
     61+            fprintf( stdout, "excluded a total of %lu bytes from checksum.\n",
     62                      bytes_excluded );
     63         }
     64     }
     65@@ -517,7 +521,7 @@ void checksum_section( const char *segme
     66 
     67             if( debug )
     68             {
     69-             fprintf( stdout, "...read section %s,%s (offset=%lu,size=%lu).\n",
     70+             fprintf( stdout, "...read section %s,%s (offset=%u,size=%u).\n",
     71                          segment_name, section_name, section.offset,
     72                          section.size );
     73             }
     74@@ -687,14 +691,14 @@ void print_stats( const char *file_path,
     75         struct group *grp;
     76 
     77         fprintf( stdout, "\nstats for (%s):\n\n", file_path );
     78-        fprintf( stdout, "      device: %lu\n", stats->st_dev );
     79-        fprintf( stdout, "       inode: %lu\n", stats->st_ino );
     80+        fprintf( stdout, "      device: %u\n", stats->st_dev );
     81+        fprintf( stdout, "       inode: %llu\n", (uint64_t)stats->st_ino );
     82 
     83         /* file permissisons string.*/
     84 
     85         get_file_attribute_string( buffer, sizeof(buffer), stats->st_mode );
     86-        fprintf( stdout, "        mode: %s (%lu)\n", buffer, stats->st_mode );
     87-        fprintf( stdout, "       links: %lu\n", stats->st_nlink );
     88+        fprintf( stdout, "        mode: %s (%hu)\n", buffer, stats->st_mode );
     89+        fprintf( stdout, "       links: %hu\n", stats->st_nlink );
     90 
     91         /* display user and group names. */
     92 
     93@@ -714,10 +718,10 @@ void print_stats( const char *file_path,
     94             safe_strlcpy( group, grp->gr_name, sizeof( group ) );
     95         }
     96 
     97-        fprintf( stdout, "         uid: %lu %s\n", stats->st_uid, name );
     98-        fprintf( stdout, "         gid: %lu %s\n", stats->st_gid, group );
     99+        fprintf( stdout, "         uid: %u %s\n", stats->st_uid, name );
     100+        fprintf( stdout, "         gid: %u %s\n", stats->st_gid, group );
     101 
     102-        fprintf( stdout, "        rdev: %lu\n", stats->st_rdev );
     103+        fprintf( stdout, "        rdev: %u\n", stats->st_rdev );
     104 
     105        /* mtime. */
     106 
     107@@ -748,9 +752,9 @@ void print_stats( const char *file_path,
     108 
     109         fprintf( stdout, "       bytes: %llu\n", stats->st_size );
     110         fprintf( stdout, "      blocks: %llu\n", stats->st_blocks );
     111-        fprintf( stdout, "  block size: %lu\n", stats->st_blksize );
     112-        fprintf( stdout, "       flags: %lu\n", stats->st_flags );
     113-        fprintf( stdout, "  gen number: %lu\n", stats->st_gen );
     114+        fprintf( stdout, "  block size: %u\n", stats->st_blksize );
     115+        fprintf( stdout, "       flags: %lu\n", (unsigned long)stats->st_flags );
     116+        fprintf( stdout, "  gen number: %lu\n", (unsigned long)stats->st_gen );
     117 
     118         fprintf( stdout, "\n" );
     119     }
     120@@ -779,7 +783,7 @@ void verify_with_knowngoods( const char
    4121         safe_strlcat( kg_get_url, file_hash, sizeof( kg_get_url ) );
    5122 
Note: See TracChangeset for help on using the changeset viewer.