mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
Improved detection of ketrings specified several times.
This commit is contained in:
parent
587104ae42
commit
d1a13319bb
3
NEWS
3
NEWS
@ -3,8 +3,9 @@ Noteworthy changes in version 1.4.8 (unreleased)
|
|||||||
|
|
||||||
* Changed the license to GPLv3.
|
* Changed the license to GPLv3.
|
||||||
|
|
||||||
|
* Improved detection of keyrings specified multiple times.
|
||||||
|
|
||||||
* Minor bug fixes.
|
* Minor bug fixes.
|
||||||
|
|
||||||
|
|
||||||
Noteworthy changes in version 1.4.7 (2007-03-05)
|
Noteworthy changes in version 1.4.7 (2007-03-05)
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2007-08-24 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* keyring.c (keyring_register_filename): Use same_file_p.
|
||||||
|
Suggested by Kurt Fitzner.
|
||||||
|
|
||||||
2007-07-19 David Shaw <dshaw@jabberwocky.com>
|
2007-07-19 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* gpg.c (main): Fix typo. Noted by John Clizbe.
|
* gpg.c (main): Fix typo. Noted by John Clizbe.
|
||||||
|
@ -207,7 +207,7 @@ keyring_register_filename (const char *fname, int secret, void **ptr)
|
|||||||
|
|
||||||
for (kr=kr_names; kr; kr = kr->next)
|
for (kr=kr_names; kr; kr = kr->next)
|
||||||
{
|
{
|
||||||
if ( !compare_filenames (kr->fname, fname) )
|
if (same_file_p (kr->fname, fname) )
|
||||||
{
|
{
|
||||||
*ptr=kr;
|
*ptr=kr;
|
||||||
return 0; /* already registered */
|
return 0; /* already registered */
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2007-08-24 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* util.h (same_file_p): Add prototype.
|
||||||
|
|
||||||
2007-06-13 David Shaw <dshaw@jabberwocky.com>
|
2007-06-13 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* cipher.h (CIPHER_ALGO_CAMELLIA): Add Camellia define.
|
* cipher.h (CIPHER_ALGO_CAMELLIA): Add Camellia define.
|
||||||
|
@ -143,6 +143,7 @@ char * make_basename(const char *filepath, const char *inputpath);
|
|||||||
char * make_dirname(const char *filepath);
|
char * make_dirname(const char *filepath);
|
||||||
char *make_filename( const char *first_part, ... );
|
char *make_filename( const char *first_part, ... );
|
||||||
int compare_filenames( const char *a, const char *b );
|
int compare_filenames( const char *a, const char *b );
|
||||||
|
int same_file_p (const char *name1, const char *name2);
|
||||||
const char *print_fname_stdin( const char *s );
|
const char *print_fname_stdin( const char *s );
|
||||||
const char *print_fname_stdout( const char *s );
|
const char *print_fname_stdout( const char *s );
|
||||||
int is_file_compressed(const char *s, int *r_status);
|
int is_file_compressed(const char *s, int *r_status);
|
||||||
|
@ -143,7 +143,7 @@ ownertrust \"Owner trust\" *Vertrauensw
|
|||||||
packet Paket
|
packet Paket
|
||||||
packet type Pakettyp
|
packet type Pakettyp
|
||||||
parse -zerlegen
|
parse -zerlegen
|
||||||
passphrase Mantra
|
passphrase Passphrase -# Mantra
|
||||||
permission [file] Zugriffsrechte
|
permission [file] Zugriffsrechte
|
||||||
Photo-ID Foto-ID
|
Photo-ID Foto-ID
|
||||||
policy Richtlinie
|
policy Richtlinie
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2007-08-24 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* fileutil.c (same_file_p): New. Taken from SVN trunk.
|
||||||
|
(compare_filenames) [HAVE_DRIVE_LETTERS]: Take drive letters and
|
||||||
|
backslashes in account.
|
||||||
|
|
||||||
2007-04-16 David Shaw <dshaw@jabberwocky.com>
|
2007-04-16 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* strgutil.c (ascii_toupper, ascii_tolower, ascii_strcasecmp,
|
* strgutil.c (ascii_toupper, ascii_tolower, ascii_strcasecmp,
|
||||||
|
112
util/fileutil.c
112
util/fileutil.c
@ -1,5 +1,5 @@
|
|||||||
/* fileutil.c - file utilities
|
/* fileutil.c - file utilities
|
||||||
* Copyright (C) 1998, 2003, 2005 Free Software Foundation, Inc.
|
* Copyright (C) 1998, 2003, 2005, 2007 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -30,6 +30,17 @@
|
|||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <ctype.h>
|
||||||
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
#else /*!HAVE_W32_SYSTEM*/
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif /*!HAVE_W32_SYSTEM*/
|
||||||
|
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "ttyio.h"
|
#include "ttyio.h"
|
||||||
@ -194,32 +205,87 @@ make_filename( const char *first_part, ... )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Compare whether the filenames are identical. This is a
|
||||||
|
special version of strcmp() taking the semantics of filenames in
|
||||||
|
account. Note that this function works only on the supplied names
|
||||||
|
without considereing any context like the current directory. See
|
||||||
|
also same_file_p(). */
|
||||||
int
|
int
|
||||||
compare_filenames( const char *a, const char *b )
|
compare_filenames (const char *a, const char *b)
|
||||||
{
|
{
|
||||||
/* ? check whether this is an absolute filename and
|
#ifdef __riscos__
|
||||||
* resolve symlinks?
|
int c = 0;
|
||||||
*/
|
char *abuf, *bbuf;
|
||||||
#ifndef __riscos__
|
|
||||||
#ifdef HAVE_DRIVE_LETTERS
|
abuf = riscos_gstrans(a);
|
||||||
return ascii_strcasecmp(a,b);
|
bbuf = riscos_gstrans(b);
|
||||||
#else
|
c = ascii_strcasecmp (abuf, bbuf);
|
||||||
return strcmp(a,b);
|
xfree(abuf);
|
||||||
|
xfree(bbuf);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
#elif defined (HAVE_DRIVE_LETTERS)
|
||||||
|
for ( ; *a && *b; a++, b++ )
|
||||||
|
{
|
||||||
|
if (*a != *b
|
||||||
|
&& (toupper (*(const unsigned char*)a)
|
||||||
|
!= toupper (*(const unsigned char*)b) )
|
||||||
|
&& !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return (toupper (*(const unsigned char*)a)
|
||||||
|
- toupper (*(const unsigned char*)b));
|
||||||
|
#else /*!HAVE_DRIVE_LETTERS*/
|
||||||
|
return strcmp (a,b);
|
||||||
#endif
|
#endif
|
||||||
#else /* __riscos__ */
|
}
|
||||||
int c = 0;
|
|
||||||
char *abuf, *bbuf;
|
|
||||||
|
|
||||||
abuf = riscos_gstrans(a);
|
/* Check whether the files NAME1 and NAME2 are identical. This is for
|
||||||
bbuf = riscos_gstrans(b);
|
example achieved by comparing the inode numbers of the files. */
|
||||||
|
int
|
||||||
c = ascii_strcasecmp (abuf, bbuf);
|
same_file_p (const char *name1, const char *name2)
|
||||||
|
{
|
||||||
xfree(abuf);
|
int yes;
|
||||||
xfree(bbuf);
|
|
||||||
|
/* First try a shortcut. */
|
||||||
return c;
|
if (!compare_filenames (name1, name2))
|
||||||
#endif /* __riscos__ */
|
yes = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
HANDLE file1, file2;
|
||||||
|
BY_HANDLE_FILE_INFORMATION info1, info2;
|
||||||
|
|
||||||
|
file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
if (file1 == INVALID_HANDLE_VALUE)
|
||||||
|
yes = 0; /* If we can't open the file, it is not the same. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file2 = CreateFile (name2, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
if (file1 == INVALID_HANDLE_VALUE)
|
||||||
|
yes = 0; /* If we can't open the file, it is not the same. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yes = (GetFileInformationByHandle (file1, &info1)
|
||||||
|
&& GetFileInformationByHandle (file2, &info2)
|
||||||
|
&& info1.dwVolumeSerialNumber==info2.dwVolumeSerialNumber
|
||||||
|
&& info1.nFileIndexHigh == info2.nFileIndexHigh
|
||||||
|
&& info1.nFileIndexLow == info2.nFileIndexLow);
|
||||||
|
CloseHandle (file2);
|
||||||
|
}
|
||||||
|
CloseHandle (file1);
|
||||||
|
}
|
||||||
|
#else /*!HAVE_W32_SYSTEM*/
|
||||||
|
struct stat info1, info2;
|
||||||
|
|
||||||
|
yes = (!stat (name1, &info1) && !stat (name2, &info2)
|
||||||
|
&& info1.st_dev == info2.st_dev && info1.st_ino == info2.st_ino);
|
||||||
|
#endif /*!HAVE_W32_SYSTEM*/
|
||||||
|
}
|
||||||
|
return yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user