mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-08 17:43:04 +01:00
fixed a stupid C error
This commit is contained in:
parent
ed17c7afd0
commit
59334400a1
1
THANKS
1
THANKS
@ -127,6 +127,7 @@ Michael Sobolev mss@despair.transas.com
|
|||||||
Michael Tokarev mjt@tls.msk.ru
|
Michael Tokarev mjt@tls.msk.ru
|
||||||
Nicolas Graner Nicolas.Graner@cri.u-psud.fr
|
Nicolas Graner Nicolas.Graner@cri.u-psud.fr
|
||||||
Mike McEwan mike@lotusland.demon.co.uk
|
Mike McEwan mike@lotusland.demon.co.uk
|
||||||
|
Neal H Walfield neal@cs.uml.edu
|
||||||
NIIBE Yutaka gniibe@chroot.org
|
NIIBE Yutaka gniibe@chroot.org
|
||||||
Niklas Hernaeus
|
Niklas Hernaeus
|
||||||
Nimrod Zimerman zimerman@forfree.at
|
Nimrod Zimerman zimerman@forfree.at
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2001-09-07 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* hkp.c (hkp_import): Use log_error. Bug reported by Neal H
|
||||||
|
Walfield.
|
||||||
|
|
||||||
|
* getkey.c (classify_user_id2): Change args to take the desc union
|
||||||
|
direct. It was a stupid idea to pass the individual fields of an
|
||||||
|
union to this function. Changed all callers.
|
||||||
|
(classify_user_id): Ditto and allow to pass NULL as the description.
|
||||||
|
|
||||||
2001-09-06 Werner Koch <wk@gnupg.org>
|
2001-09-06 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* getkey.c (fixup_uidnode): Features flag is now a bit vector.
|
* getkey.c (fixup_uidnode): Features flag is now a bit vector.
|
||||||
|
@ -63,13 +63,7 @@ do_delete_key( const char *username, int secret, int *r_sec_avail )
|
|||||||
*r_sec_avail = 0;
|
*r_sec_avail = 0;
|
||||||
|
|
||||||
/* search the userid */
|
/* search the userid */
|
||||||
memset (&desc, 0, sizeof desc);
|
classify_user_id (username, &desc);
|
||||||
desc.mode = classify_user_id (username,
|
|
||||||
desc.u.kid,
|
|
||||||
desc.u.fpr,
|
|
||||||
&desc.u.name,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
rc = desc.mode? keydb_search (hd, &desc, 1):G10ERR_INV_USER_ID;
|
rc = desc.mode? keydb_search (hd, &desc, 1):G10ERR_INV_USER_ID;
|
||||||
if (rc) {
|
if (rc) {
|
||||||
log_error (_("key `%s' not found: %s\n"), username, g10_errstr (rc));
|
log_error (_("key `%s' not found: %s\n"), username, g10_errstr (rc));
|
||||||
|
@ -143,9 +143,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any )
|
|||||||
else {
|
else {
|
||||||
KEYDB_SEARCH_DESC desc;
|
KEYDB_SEARCH_DESC desc;
|
||||||
|
|
||||||
memset (&desc, 0, sizeof desc);
|
classify_user_id (sl->d, &desc);
|
||||||
desc.mode = classify_user_id (sl->d, desc.u.kid, desc.u.fpr,
|
|
||||||
&desc.u.name, NULL);
|
|
||||||
rc = desc.mode? keydb_search (kdbhd, &desc, 1):G10ERR_INV_USER_ID;
|
rc = desc.mode? keydb_search (kdbhd, &desc, 1):G10ERR_INV_USER_ID;
|
||||||
if( rc ) {
|
if( rc ) {
|
||||||
log_error (_("key `%s' not found: %s\n"),
|
log_error (_("key `%s' not found: %s\n"),
|
||||||
|
111
g10/getkey.c
111
g10/getkey.c
@ -543,8 +543,6 @@ hextobyte( const byte *s )
|
|||||||
* 21 = Unified fingerprint :fpr:pk_algo:
|
* 21 = Unified fingerprint :fpr:pk_algo:
|
||||||
* (We don't use pk_algo yet)
|
* (We don't use pk_algo yet)
|
||||||
*
|
*
|
||||||
* if fprint is not NULL, it should be an array of at least 20 bytes.
|
|
||||||
*
|
|
||||||
* Rules used:
|
* Rules used:
|
||||||
* - If the username starts with 8,9,16 or 17 hex-digits (the first one
|
* - If the username starts with 8,9,16 or 17 hex-digits (the first one
|
||||||
* must be in the range 0..9), this is considered a keyid; depending
|
* must be in the range 0..9), this is considered a keyid; depending
|
||||||
@ -570,16 +568,20 @@ hextobyte( const byte *s )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
classify_user_id2( const char *name,
|
||||||
const char **retstr, size_t *retlen, int *force_exact )
|
KEYDB_SEARCH_DESC *desc,
|
||||||
|
int *force_exact )
|
||||||
{
|
{
|
||||||
const char * s;
|
const char *s;
|
||||||
int mode = 0;
|
int hexprefix = 0;
|
||||||
int hexprefix = 0;
|
int hexlength;
|
||||||
int hexlength;
|
int mode = 0;
|
||||||
|
|
||||||
|
/* clear the structure so that the mode field is set to zero unless
|
||||||
|
* we set it to the correct value right at the end of this function */
|
||||||
|
memset (desc, 0, sizeof *desc);
|
||||||
*force_exact = 0;
|
*force_exact = 0;
|
||||||
/* skip leading spaces. FIXME: what is with leading spaces? */
|
/* skip leading spaces. Fixme: what is with trailing spaces? */
|
||||||
for(s = name; *s && isspace(*s); s++ )
|
for(s = name; *s && isspace(*s); s++ )
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -590,39 +592,43 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
case '.': /* an email address, compare from end */
|
case '.': /* an email address, compare from end */
|
||||||
mode = KEYDB_SEARCH_MODE_MAILEND;
|
mode = KEYDB_SEARCH_MODE_MAILEND;
|
||||||
s++;
|
s++;
|
||||||
|
desc->u.name = s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '<': /* an email address */
|
case '<': /* an email address */
|
||||||
mode = KEYDB_SEARCH_MODE_MAIL;
|
mode = KEYDB_SEARCH_MODE_MAIL;
|
||||||
|
desc->u.name = s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '@': /* part of an email address */
|
case '@': /* part of an email address */
|
||||||
mode = KEYDB_SEARCH_MODE_MAILSUB;
|
mode = KEYDB_SEARCH_MODE_MAILSUB;
|
||||||
s++;
|
s++;
|
||||||
|
desc->u.name = s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '=': /* exact compare */
|
case '=': /* exact compare */
|
||||||
mode = KEYDB_SEARCH_MODE_EXACT;
|
mode = KEYDB_SEARCH_MODE_EXACT;
|
||||||
s++;
|
s++;
|
||||||
|
desc->u.name = s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '*': /* case insensitive substring search */
|
case '*': /* case insensitive substring search */
|
||||||
mode = KEYDB_SEARCH_MODE_SUBSTR;
|
mode = KEYDB_SEARCH_MODE_SUBSTR;
|
||||||
s++;
|
s++;
|
||||||
|
desc->u.name = s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '+': /* compare individual words */
|
case '+': /* compare individual words */
|
||||||
mode = KEYDB_SEARCH_MODE_WORDS;
|
mode = KEYDB_SEARCH_MODE_WORDS;
|
||||||
s++;
|
s++;
|
||||||
|
desc->u.name = s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '#': /* local user id */
|
case '#': /* local user id */
|
||||||
mode = KEYDB_SEARCH_MODE_TDBIDX;
|
mode = KEYDB_SEARCH_MODE_TDBIDX;
|
||||||
s++;
|
s++;
|
||||||
if (keyid) {
|
if (keyid_from_lid(strtoul(s, NULL, 10), desc->u.kid))
|
||||||
if (keyid_from_lid(strtoul(s, NULL, 10), keyid))
|
desc->u.kid[0] = desc->u.kid[1] = 0;
|
||||||
keyid[0] = keyid[1] = 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ':': /*Unified fingerprint */
|
case ':': /*Unified fingerprint */
|
||||||
@ -639,12 +645,10 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
}
|
}
|
||||||
if (i != 32 && i != 40)
|
if (i != 32 && i != 40)
|
||||||
return 0; /* invalid length of fpr*/
|
return 0; /* invalid length of fpr*/
|
||||||
if (fprint) {
|
for (i=0,si=s; si < se; i++, si +=2)
|
||||||
for (i=0,si=s; si < se; i++, si +=2)
|
desc->u.fpr[i] = hextobyte(si);
|
||||||
fprint[i] = hextobyte(si);
|
for ( ; i < 20; i++)
|
||||||
for ( ; i < 20; i++)
|
desc->u.fpr[i]= 0;
|
||||||
fprint[i]= 0;
|
|
||||||
}
|
|
||||||
s = se + 1;
|
s = se + 1;
|
||||||
mode = KEYDB_SEARCH_MODE_FPR;
|
mode = KEYDB_SEARCH_MODE_FPR;
|
||||||
}
|
}
|
||||||
@ -678,10 +682,8 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
/* short keyid */
|
/* short keyid */
|
||||||
if (hexlength == 9)
|
if (hexlength == 9)
|
||||||
s++;
|
s++;
|
||||||
if (keyid) {
|
desc->u.kid[0] = 0;
|
||||||
keyid[0] = 0;
|
desc->u.kid[1] = strtoul( s, NULL, 16 );
|
||||||
keyid[1] = strtoul( s, NULL, 16 );
|
|
||||||
}
|
|
||||||
mode = KEYDB_SEARCH_MODE_SHORT_KID;
|
mode = KEYDB_SEARCH_MODE_SHORT_KID;
|
||||||
}
|
}
|
||||||
else if (hexlength == 16
|
else if (hexlength == 16
|
||||||
@ -691,8 +693,8 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
if (hexlength == 17)
|
if (hexlength == 17)
|
||||||
s++;
|
s++;
|
||||||
mem2str(buf, s, 9 );
|
mem2str(buf, s, 9 );
|
||||||
keyid[0] = strtoul( buf, NULL, 16 );
|
desc->u.kid[0] = strtoul( buf, NULL, 16 );
|
||||||
keyid[1] = strtoul( s+8, NULL, 16 );
|
desc->u.kid[1] = strtoul( s+8, NULL, 16 );
|
||||||
mode = KEYDB_SEARCH_MODE_LONG_KID;
|
mode = KEYDB_SEARCH_MODE_LONG_KID;
|
||||||
}
|
}
|
||||||
else if (hexlength == 32 || (!hexprefix && hexlength == 33
|
else if (hexlength == 32 || (!hexprefix && hexlength == 33
|
||||||
@ -701,15 +703,13 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
int i;
|
int i;
|
||||||
if (hexlength == 33)
|
if (hexlength == 33)
|
||||||
s++;
|
s++;
|
||||||
if (fprint) {
|
memset(desc->u.fpr+16, 0, 4);
|
||||||
memset(fprint+16, 0, 4);
|
for (i=0; i < 16; i++, s+=2) {
|
||||||
for (i=0; i < 16; i++, s+=2) {
|
int c = hextobyte(s);
|
||||||
int c = hextobyte(s);
|
if (c == -1)
|
||||||
if (c == -1)
|
return 0;
|
||||||
return 0;
|
desc->u.fpr[i] = c;
|
||||||
fprint[i] = c;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
mode = KEYDB_SEARCH_MODE_FPR16;
|
mode = KEYDB_SEARCH_MODE_FPR16;
|
||||||
}
|
}
|
||||||
else if (hexlength == 40 || (!hexprefix && hexlength == 41
|
else if (hexlength == 40 || (!hexprefix && hexlength == 41
|
||||||
@ -718,14 +718,12 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
int i;
|
int i;
|
||||||
if (hexlength == 41)
|
if (hexlength == 41)
|
||||||
s++;
|
s++;
|
||||||
if (fprint) {
|
for (i=0; i < 20; i++, s+=2) {
|
||||||
for (i=0; i < 20; i++, s+=2) {
|
int c = hextobyte(s);
|
||||||
int c = hextobyte(s);
|
if (c == -1)
|
||||||
if (c == -1)
|
return 0;
|
||||||
return 0;
|
desc->u.fpr[i] = c;
|
||||||
fprint[i] = c;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
mode = KEYDB_SEARCH_MODE_FPR20;
|
mode = KEYDB_SEARCH_MODE_FPR20;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -733,24 +731,24 @@ classify_user_id2( const char *name, u32 *keyid, byte *fprint,
|
|||||||
return 0; /* and a wrong length */
|
return 0; /* and a wrong length */
|
||||||
|
|
||||||
*force_exact = 0;
|
*force_exact = 0;
|
||||||
|
desc->u.name = s;
|
||||||
mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */
|
mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( retstr )
|
desc->mode = mode;
|
||||||
*retstr = s;
|
|
||||||
if( retlen )
|
|
||||||
*retlen = strlen(s);
|
|
||||||
|
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
classify_user_id( const char *name, u32 *keyid, byte *fprint,
|
classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc)
|
||||||
const char **retstr, size_t *retlen )
|
|
||||||
{
|
{
|
||||||
int dummy;
|
int dummy;
|
||||||
return classify_user_id2 (name, keyid, fprint, retstr, retlen, &dummy);
|
KEYDB_SEARCH_DESC dummy_desc;
|
||||||
|
|
||||||
|
if (!desc)
|
||||||
|
desc = &dummy_desc;
|
||||||
|
return classify_user_id2 (name, desc, &dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
@ -789,17 +787,12 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
|||||||
ctx->nitems = n;
|
ctx->nitems = n;
|
||||||
|
|
||||||
for(n=0, r=namelist; r; r = r->next, n++ ) {
|
for(n=0, r=namelist; r; r = r->next, n++ ) {
|
||||||
int mode = classify_user_id2 ( r->d,
|
classify_user_id2 (r->d, &ctx->items[n], &exact);
|
||||||
ctx->items[n].u.kid,
|
|
||||||
ctx->items[n].u.fpr,
|
|
||||||
&ctx->items[n].u.name,
|
|
||||||
NULL, &exact );
|
|
||||||
|
|
||||||
if ( exact )
|
if (exact)
|
||||||
ctx->exact = 1;
|
ctx->exact = 1;
|
||||||
ctx->items[n].mode = mode;
|
if (!ctx->items[n].mode) {
|
||||||
if( !ctx->items[n].mode ) {
|
m_free (ctx);
|
||||||
m_free( ctx );
|
|
||||||
return G10ERR_INV_USER_ID;
|
return G10ERR_INV_USER_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
g10/hkp.c
12
g10/hkp.c
@ -104,17 +104,19 @@ hkp_import( STRLIST users )
|
|||||||
}
|
}
|
||||||
|
|
||||||
for( ; users; users = users->next ) {
|
for( ; users; users = users->next ) {
|
||||||
u32 kid[2];
|
KEYDB_SEARCH_DESC desc;
|
||||||
int type = classify_user_id( users->d, kid, NULL, NULL, NULL );
|
|
||||||
if( type != 10 && type != 11 ) {
|
classify_user_id (users->d, &desc);
|
||||||
log_info(_("%s: not a valid key ID\n"), users->d );
|
if( desc.mode != KEYDB_SEARCH_MODE_SHORT_KID
|
||||||
|
&& desc.mode != KEYDB_SEARCH_MODE_LONG_KID ) {
|
||||||
|
log_error (_("%s: not a valid key ID\n"), users->d );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* because the function may use log_info in some situations, the
|
/* because the function may use log_info in some situations, the
|
||||||
* errorcounter ist not increaed and the program will return
|
* errorcounter ist not increaed and the program will return
|
||||||
* with success - which is not good when this function is used.
|
* with success - which is not good when this function is used.
|
||||||
*/
|
*/
|
||||||
if( hkp_ask_import( kid ) )
|
if( hkp_ask_import( desc.u.kid ) )
|
||||||
log_inc_errorcount();
|
log_inc_errorcount();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -177,8 +177,7 @@ void set_next_passphrase( const char *s );
|
|||||||
char *get_last_passphrase(void);
|
char *get_last_passphrase(void);
|
||||||
|
|
||||||
/*-- getkey.c --*/
|
/*-- getkey.c --*/
|
||||||
int classify_user_id( const char *name, u32 *keyid, byte *fprint,
|
int classify_user_id( const char *name, KEYDB_SEARCH_DESC *desc);
|
||||||
const char **retstr, size_t *retlen );
|
|
||||||
void cache_public_key( PKT_public_key *pk );
|
void cache_public_key( PKT_public_key *pk );
|
||||||
void getkey_disable_caches(void);
|
void getkey_disable_caches(void);
|
||||||
int get_pubkey( PKT_public_key *pk, u32 *keyid );
|
int get_pubkey( PKT_public_key *pk, u32 *keyid );
|
||||||
|
@ -945,6 +945,8 @@ ask_expire_interval(void)
|
|||||||
/* print the date when the key expires */
|
/* print the date when the key expires */
|
||||||
tty_printf(_("Key expires at %s\n"),
|
tty_printf(_("Key expires at %s\n"),
|
||||||
asctimestamp((ulong)(curtime + interval) ) );
|
asctimestamp((ulong)(curtime + interval) ) );
|
||||||
|
/* FIXME: This check yields warning on alhas:
|
||||||
|
write a configure check and to this check here only for 32 bit machines */
|
||||||
if( (time_t)((ulong)(curtime+interval)) < 0 )
|
if( (time_t)((ulong)(curtime+interval)) < 0 )
|
||||||
tty_printf(_("Your system can't display dates beyond 2038.\n"
|
tty_printf(_("Your system can't display dates beyond 2038.\n"
|
||||||
"However, it will be correctly handled up to 2106.\n"));
|
"However, it will be correctly handled up to 2106.\n"));
|
||||||
|
@ -104,12 +104,7 @@ gen_revoke( const char *uname )
|
|||||||
* We don't want the whole getkey stuff here but the entire keyblock
|
* We don't want the whole getkey stuff here but the entire keyblock
|
||||||
*/
|
*/
|
||||||
kdbhd = keydb_new (1);
|
kdbhd = keydb_new (1);
|
||||||
memset (&desc, 0, sizeof desc);
|
classify_user_id (uname, &desc);
|
||||||
desc.mode = classify_user_id (uname,
|
|
||||||
desc.u.kid,
|
|
||||||
desc.u.fpr,
|
|
||||||
&desc.u.name,
|
|
||||||
NULL);
|
|
||||||
rc = desc.mode? keydb_search (kdbhd, &desc, 1) : G10ERR_INV_USER_ID;
|
rc = desc.mode? keydb_search (kdbhd, &desc, 1) : G10ERR_INV_USER_ID;
|
||||||
if (rc) {
|
if (rc) {
|
||||||
log_error (_("secret key `%s' not found: %s\n"),
|
log_error (_("secret key `%s' not found: %s\n"),
|
||||||
|
@ -467,20 +467,20 @@ lid_from_keyid_no_sdir( u32 *keyid )
|
|||||||
void
|
void
|
||||||
register_trusted_key( const char *string )
|
register_trusted_key( const char *string )
|
||||||
{
|
{
|
||||||
u32 keyid[2];
|
KEYDB_SEARCH_DESC desc;
|
||||||
struct keyid_list *r;
|
struct keyid_list *r;
|
||||||
|
|
||||||
if( classify_user_id( string, keyid, NULL, NULL, NULL ) != 11 ) {
|
if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID ) {
|
||||||
log_error(_("'%s' is not a valid long keyID\n"), string );
|
log_error(_("`%s' is not a valid long keyID\n"), string );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( r = trusted_key_list; r; r = r->next )
|
for( r = trusted_key_list; r; r = r->next )
|
||||||
if( r->keyid[0] == keyid[0] && r->keyid[1] == keyid[1] )
|
if( r->keyid[0] == desc.u.kid[0] && r->keyid[1] == desc.u.kid[1] )
|
||||||
return;
|
return;
|
||||||
r = m_alloc( sizeof *r );
|
r = m_alloc( sizeof *r );
|
||||||
r->keyid[0] = keyid[0];
|
r->keyid[0] = desc.u.kid[0];
|
||||||
r->keyid[1] = keyid[1];
|
r->keyid[1] = desc.u.kid[1];
|
||||||
r->next = trusted_key_list;
|
r->next = trusted_key_list;
|
||||||
trusted_key_list = r;
|
trusted_key_list = r;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user