diff options
author | Werner Koch <[email protected]> | 2000-09-18 14:35:34 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2000-09-18 14:35:34 +0000 |
commit | 986d928ce2a561b04fda7730de6a94f9b1e703d6 (patch) | |
tree | 9d815bcf427ee76f678153f4b000d8843816a2bd /util | |
parent | See ChangeLog: Tue Aug 22 14:31:15 CEST 2000 Werner Koch (diff) | |
download | gnupg-986d928ce2a561b04fda7730de6a94f9b1e703d6.tar.gz gnupg-986d928ce2a561b04fda7730de6a94f9b1e703d6.zip |
See ChangeLog: Mon Sep 18 16:35:45 CEST 2000 Werner Koch
Diffstat (limited to 'util')
-rw-r--r-- | util/ChangeLog | 12 | ||||
-rw-r--r-- | util/iobuf.c | 29 | ||||
-rw-r--r-- | util/miscutil.c | 8 | ||||
-rw-r--r-- | util/strgutil.c | 7 |
4 files changed, 48 insertions, 8 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index 956c2085d..20e9bda3e 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,15 @@ +Mon Sep 18 16:35:45 CEST 2000 Werner Koch <[email protected]> + + * strgutil.c (utf8_to_native): Fixed null ptr problem. By + Giampaolo Tomassoni. + + * iobuf.c: Use fopen64 insead of fopen when available. + (iobuf_get_filelength): Use fstat64 when available but return + 2^32-1 if the file is larger than this value. + + * miscutil.c (answer_is_yes_no_quit): Swapped order of yes/no test + so that no is returned for an empty input. By David Champion. + Fri Aug 18 14:27:14 CEST 2000 Werner Koch <[email protected]> * logger.c (log_set_file): Allow to set the file by name. diff --git a/util/iobuf.c b/util/iobuf.c index f7035ae4c..5f70694c2 100644 --- a/util/iobuf.c +++ b/util/iobuf.c @@ -36,6 +36,14 @@ #include "util.h" #include "iobuf.h" + +#if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64) + #define fopen(a,b) fopen64 ((a),(b)) + #define fstat(a,b) fstat64 ((a),(b)) +#endif + + + typedef struct { FILE *fp; /* open file handle */ int print_only_name; /* flags indicating that fname is not a real file*/ @@ -1312,25 +1320,40 @@ iobuf_set_limit( IOBUF a, unsigned long nlimit ) u32 iobuf_get_filelength( IOBUF a ) { +#if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64) + struct stat64 st; +#else struct stat st; +#endif if( a->directfp ) { FILE *fp = a->directfp; - if( !fstat(fileno(fp), &st) ) - return st.st_size; + if( !fstat(fileno(fp), &st) ) { + #if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64) + if( st.st_size >= IOBUF_FILELENGTH_LIMIT ) + return IOBUF_FILELENGTH_LIMIT; + #endif + return (u32)st.st_size; + } log_error("fstat() failed: %s\n", strerror(errno) ); return 0; } + /* Hmmm: file_filter may have already been removed */ for( ; a; a = a->chain ) if( !a->chain && a->filter == file_filter ) { file_filter_ctx_t *b = a->filter_ov; FILE *fp = b->fp; - if( !fstat(fileno(fp), &st) ) + if( !fstat(fileno(fp), &st) ) { + #if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64) + if( st.st_size >= IOBUF_FILELENGTH_LIMIT ) + return IOBUF_FILELENGTH_LIMIT; + #endif return st.st_size; + } log_error("fstat() failed: %s\n", strerror(errno) ); break; } diff --git a/util/miscutil.c b/util/miscutil.c index c1b8fa076..9b4a8379f 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -311,16 +311,16 @@ answer_is_yes_no_quit( const char *s ) char *short_no = _("nN"); char *short_quit = _("qQ"); - if( !stricmp(s, long_yes ) ) - return 1; if( !stricmp(s, long_no ) ) return 0; + if( !stricmp(s, long_yes ) ) + return 1; if( !stricmp(s, long_quit ) ) return -1; - if( strchr( short_yes, *s ) && !s[1] ) - return 1; if( strchr( short_no, *s ) && !s[1] ) return 0; + if( strchr( short_yes, *s ) && !s[1] ) + return 1; if( strchr( short_quit, *s ) && !s[1] ) return -1; if( !stricmp(s, "yes" ) ) diff --git a/util/strgutil.c b/util/strgutil.c index a8abf7ba8..89722f8e4 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -389,7 +389,8 @@ utf8_to_native( const char *string, size_t length ) case 0 : n++; if( p ) *p++ = '0'; break; default: n += 3; sprintf( p, "x%02x", *s ); - p += 3; + if ( p ) + p += 3; break; } } @@ -496,3 +497,7 @@ utf8_to_native( const char *string, size_t length ) } + + + + |