X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=bin%2Fmegatron%2Fasingle.c;h=60c754f0ac8fae5a6acd4679c806b8e6f7352007;hb=refs%2Ftags%2Fbranch-dircache-rewrite-start;hp=b9756e82e91dc43f6d2168a5b570f2b81bd3548e;hpb=815d557e167e76015934397dffbfa869180dcdbc;p=netatalk.git diff --git a/bin/megatron/asingle.c b/bin/megatron/asingle.c index b9756e82..60c754f0 100644 --- a/bin/megatron/asingle.c +++ b/bin/megatron/asingle.c @@ -1,5 +1,5 @@ /* - * $Id: asingle.c,v 1.12 2009-10-13 22:55:36 didg Exp $ + * $Id: asingle.c,v 1.14 2010-01-27 21:27:53 didg Exp $ */ #ifdef HAVE_CONFIG_H @@ -47,14 +47,14 @@ following globals; therefore this module can only be used for one of the two functions at a time. */ -struct single_file_data { +static struct single_file_data { int filed; char path[ MAXPATHLEN + 1]; struct ad_entry entry[ ADEID_MAX ]; } single; extern char *forkname[]; -u_char header_buf[ AD_HEADER_LEN ]; +static u_char header_buf[ AD_HEADER_LEN ]; /* * single_open must be called first. pass it a filename that is supposed @@ -333,7 +333,7 @@ int single_header_read( struct FHeader *fh, int version) * "Macintosh " (that is seven blanks of padding). */ #define MACINTOSH "Macintosh " -u_char sixteennulls[] = { 0, 0, 0, 0, 0, 0, 0, 0, +static u_char sixteennulls[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int single_header_test(void) @@ -389,12 +389,12 @@ int single_header_test(void) * */ -int single_read( int fork, char *buffer, u_int32_t length) +ssize_t single_read( int fork, char *buffer, size_t length) { u_int32_t entry_id; char *buf_ptr; - int readlen; - int cc = 1; + size_t readlen; + ssize_t cc = 1; off_t pos; switch ( fork ) { @@ -409,9 +409,9 @@ int single_read( int fork, char *buffer, u_int32_t length) break; } - if (single.entry[entry_id].ade_len > length) { - fprintf(stderr, "single_read: Trying to read past end of fork!, length %d, ade_len == %u\n", length, single.entry[entry_id].ade_len); - return single.entry[entry_id].ade_len; + if (single.entry[entry_id].ade_len > 0x7FFFFFFF) { + fprintf(stderr, "single_read: Trying to read past end of fork!, ade_len == %u\n", single.entry[entry_id].ade_len); + return -1; } if ( single.entry[ entry_id ].ade_len == 0 ) { if ( fork == DATA ) {