aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1999-01-17 10:06:03 +0000
committerWerner Koch <[email protected]>1999-01-17 10:06:03 +0000
commitbefacf7efa649de7ee4421a154cc06a40a181cf2 (patch)
tree8197e739f35fbe9d4afa9dc96cfa82aee75d74f5
parentSee ChangeLog: Sat Jan 16 21:25:17 CET 1999 Werner Koch (diff)
downloadgnupg-befacf7efa649de7ee4421a154cc06a40a181cf2.tar.gz
gnupg-befacf7efa649de7ee4421a154cc06a40a181cf2.zip
See ChangeLog: Sun Jan 17 11:04:33 CET 1999 Werner Koch
-rw-r--r--cipher/ChangeLog10
-rw-r--r--cipher/blowfish.c22
-rw-r--r--cipher/cast5.c23
-rw-r--r--cipher/des.c52
-rw-r--r--cipher/twofish.c25
-rw-r--r--g10/ChangeLog8
-rw-r--r--g10/armor.c30
-rw-r--r--g10/filter.h9
-rw-r--r--g10/free-packet.c5
-rw-r--r--g10/sign.c2
-rw-r--r--g10/textfilter.c117
-rw-r--r--include/errors.h1
-rw-r--r--include/util.h1
-rw-r--r--po/POTFILES.in1
-rw-r--r--scripts/ChangeLog4
-rwxr-xr-xscripts/autogen.sh12
-rw-r--r--util/ChangeLog4
-rw-r--r--util/errors.c1
-rw-r--r--util/strgutil.c28
19 files changed, 199 insertions, 156 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index a17ed34b4..c46ca5d86 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,13 @@
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <[email protected]>
+
+ * des.c (is_weak_key): Replace system memcmp due to bugs
+ in SunOS's memcmp.
+ (des_get_info): Return error on failed selftest.
+ * twofish.c (twofish_setkey): Return error on failed selftest or
+ invalid keylength.
+ * cast5.c (cast_setkey): Ditto.
+ * blowfish.c (bf_setkey): Return error on failed selftest.
+
Tue Jan 12 11:17:18 CET 1999 Werner Koch <[email protected]>
* random.c (random_is_faked): New.
diff --git a/cipher/blowfish.c b/cipher/blowfish.c
index fdc4c4bfb..3bbc03835 100644
--- a/cipher/blowfish.c
+++ b/cipher/blowfish.c
@@ -34,10 +34,12 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include "util.h"
#include "types.h"
+#include "errors.h"
#include "blowfish.h"
+
+
#define CIPHER_ALGO_BLOWFISH 4 /* blowfish 128 bit key */
#define CIPHER_ALGO_BLOWFISH160 42 /* blowfish 160 bit key (not in OpenPGP)*/
@@ -451,7 +453,7 @@ decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
}
-static void
+static const char*
selftest()
{
BLOWFISH_context c;
@@ -464,18 +466,19 @@ selftest()
bf_setkey( &c, "abcdefghijklmnopqrstuvwxyz", 26 );
encrypt_block( &c, buffer, plain );
if( memcmp( buffer, "\x32\x4E\xD0\xFE\xF4\x13\xA2\x03", 8 ) )
- log_error("wrong blowfish encryption\n");
+ return "Blowfish selftest failed (1).";
decrypt_block( &c, buffer, buffer );
if( memcmp( buffer, plain, 8 ) )
- log_bug("blowfish failed\n");
+ return "Blowfish selftest failed (2).";
bf_setkey( &c, key3, 8 );
encrypt_block( &c, buffer, plain3 );
if( memcmp( buffer, cipher3, 8 ) )
- log_error("wrong blowfish encryption (3)\n");
+ return "Blowfish selftest failed (3).";
decrypt_block( &c, buffer, buffer );
if( memcmp( buffer, plain3, 8 ) )
- log_bug("blowfish failed (3)\n");
+ return "Blowfish selftest failed (4).";
+ return NULL;
}
@@ -486,11 +489,16 @@ bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
int i, j;
u32 data, datal, datar;
static int initialized;
+ static const char *selftest_failed;
if( !initialized ) {
initialized = 1;
- selftest();
+ selftest_failed = selftest();
+ if( selftest_failed )
+ fprintf(stderr,"%s\n", selftest_failed );
}
+ if( selftest_failed )
+ return G10ERR_SELFTEST_FAILED;
for(i=0; i < BLOWFISH_ROUNDS+2; i++ )
c->p[i] = ps[i];
diff --git a/cipher/cast5.c b/cipher/cast5.c
index 279838fa3..6f131ca23 100644
--- a/cipher/cast5.c
+++ b/cipher/cast5.c
@@ -39,9 +39,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
-#include "util.h"
#include "types.h"
+#include "errors.h"
#include "cast5.h"
@@ -455,7 +454,7 @@ decrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
-static void
+static const char*
selftest()
{
CAST5_context c;
@@ -468,10 +467,10 @@ selftest()
cast_setkey( &c, key, 16 );
encrypt_block( &c, buffer, plain );
if( memcmp( buffer, cipher, 8 ) )
- log_error("wrong cast5-128 encryption\n");
+ return "1";
decrypt_block( &c, buffer, buffer );
if( memcmp( buffer, plain, 8 ) )
- log_bug("cast5-128 failed\n");
+ return "2";
#if 0 /* full maintenance test */
{
@@ -494,10 +493,11 @@ selftest()
encrypt_block( &c, b0+8, b0+8 );
}
if( memcmp( a0, a1, 16 ) || memcmp( b0, b1, 16 ) )
- log_bug("cast5-128 maintenance test failed\n");
+ return "3";
}
#endif
+ return NULL;
}
@@ -553,6 +553,7 @@ static int
cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
{
static int initialized;
+ static const char* selftest_failed;
int i;
u32 x[4];
u32 z[4];
@@ -560,10 +561,16 @@ cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
if( !initialized ) {
initialized = 1;
- selftest();
+ selftest_failed = selftest();
+ if( selftest_failed )
+ fprintf(stderr,"CAST5 selftest failed (%s).\n", selftest_failed );
}
+ if( selftest_failed )
+ return G10ERR_SELFTEST_FAILED;
+
+ if( keylen != 16 )
+ return G10ERR_WRONG_KEYLEN;
- assert(keylen==16);
x[0] = key[0] << 24 | key[1] << 16 | key[2] << 8 | key[3];
x[1] = key[4] << 24 | key[5] << 16 | key[6] << 8 | key[7];
x[2] = key[8] << 24 | key[9] << 16 | key[10] << 8 | key[11];
diff --git a/cipher/des.c b/cipher/des.c
index 41c768894..088f5e142 100644
--- a/cipher/des.c
+++ b/cipher/des.c
@@ -113,12 +113,30 @@
#include <config.h>
+#include <stdio.h>
#include <string.h> /* memcpy, memcmp */
-#include <assert.h>
#include "types.h" /* for byte and u32 typedefs */
-#include "util.h" /* for log_fatal() */
+#include "errors.h"
#include "des.h"
+#if defined(__GNUC__) && defined(__GNU_LIBRARY__)
+#define working_memcmp memcmp
+#else
+/*
+ * According to the SunOS man page, memcmp returns indeterminate sign
+ * depending on whether characters are signed or not.
+ */
+int
+working_memcmp( const char *a, const char *b, size_t n )
+{
+ for( ; n; n--, a++, b++ )
+ if( *a != *b )
+ return (int)(*(byte*)a) - (int)(*(byte*)b);
+ return 0;
+}
+#endif
+
+
/* Some defines/checks to support standalone modules */
@@ -128,19 +146,6 @@
#error CIPHER_ALGO_3DES is defined to a wrong value.
#endif
-#ifndef G10ERR_WEAK_KEY
- #define G10ERR_WEAK_KEY 43
-#elif G10ERR_WEAK_KEY != 43
- #error G10ERR_WEAK_KEY is defined to a wrong value.
-#endif
-
-#ifndef G10ERR_WRONG_KEYLEN
- #define G10ERR_WRONG_KEYLEN 44
-#elif G10ERR_WRONG_KEYLEN != 44
- #error G10ERR_WRONG_KEYLEN is defined to a wrong value.
-#endif
-
-
/* Macros used by the info function. */
#define FNCCAST_SETKEY(f) ((int(*)(void*, byte*, unsigned))(f))
@@ -167,6 +172,7 @@ typedef struct _tripledes_ctx
}
tripledes_ctx[1];
+static const char *selftest_failed;
static void des_key_schedule (const byte *, u32 *);
static int des_setkey (struct _des_ctx *, const byte *);
@@ -542,6 +548,9 @@ des_setkey (struct _des_ctx *ctx, const byte * key)
{
int i;
+ if( selftest_failed )
+ return G10ERR_SELFTEST_FAILED;
+
des_key_schedule (key, ctx->encrypt_subkeys);
for(i=0; i<32; i+=2)
@@ -706,6 +715,8 @@ tripledes_ecb_crypt (struct _tripledes_ctx *ctx, const byte * from, byte * to, i
+
+
/*
* Check whether the 8 byte key is weak.
* Dose not check the parity bits of the key but simple ignore them.
@@ -727,7 +738,7 @@ is_weak_key ( const byte *key )
{
middle = (left + right) / 2;
- if ( !(cmp_result=memcmp(work, weak_keys[middle], 8)) )
+ if ( !(cmp_result=working_memcmp(work, weak_keys[middle], 8)) )
return -1;
if ( cmp_result > 0 )
@@ -836,6 +847,8 @@ selftest (void)
static int
do_tripledes_setkey ( struct _tripledes_ctx *ctx, byte *key, unsigned keylen )
{
+ if( selftest_failed )
+ return G10ERR_SELFTEST_FAILED;
if( keylen != 24 )
return G10ERR_WRONG_KEYLEN;
@@ -879,9 +892,12 @@ des_get_info( int algo, size_t *keylen,
if( !did_selftest ) {
const char *s = selftest();
- if( s )
- log_fatal("selftest failed: %s\n", s );
did_selftest = 1;
+ if( s ) {
+ fprintf(stderr,"%s\n", s );
+ selftest_failed = s;
+ return NULL;
+ }
}
diff --git a/cipher/twofish.c b/cipher/twofish.c
index d93c145ea..d52377f76 100644
--- a/cipher/twofish.c
+++ b/cipher/twofish.c
@@ -19,14 +19,14 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
-#include <assert.h> /* for assert() */
#include <string.h> /* for memcmp() */
#include "types.h" /* for byte and u32 typedefs */
-#include "util.h" /* for log_fatal() */
+#include "errors.h"
+
/* Prototype for the self-test function. */
-static void selftest(void);
+static const char *selftest(void);
/* Macros used by the info function. */
#define FNCCAST_SETKEY(f) ((int(*)(void*, byte*, unsigned))(f))
@@ -456,17 +456,23 @@ twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen)
/* Temporary for CALC_S. */
byte tmp;
- /* Flag for self-test. */
+ /* Flags for self-test. */
static int initialized = 0;
+ static const char *selftest_failed=0;
/* Check key length. */
- assert (keylen == 16);
+ if( keylen != 16 )
+ return G10ERR_WRONG_KEYLEN;
/* Do self-test if necessary. */
if (!initialized) {
initialized = 1;
- selftest ();
+ selftest_failed = selftest ();
+ if( selftest_failed )
+ fprintf(stderr, "%s\n", selftest_failed );
}
+ if( selftest_failed )
+ return G10ERR_SELFTEST_FAILED;
/* Compute the S vector. The magic numbers are the entries of the RS
* matrix, preprocessed through poly_to_exp. The numbers in the comments
@@ -709,7 +715,7 @@ twofish_decrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
/* Test a single encryption and decryption, as a sanity check. */
-static void
+static const char*
selftest (void)
{
TWOFISH_context ctx; /* Expanded key. */
@@ -736,10 +742,11 @@ selftest (void)
twofish_setkey (&ctx, key, sizeof(key));
twofish_encrypt (&ctx, scratch, plaintext);
if (memcmp (scratch, ciphertext, sizeof (ciphertext)))
- log_fatal ("Twofish test encryption failed\n");
+ return "Twofish test encryption failed.";
twofish_decrypt (&ctx, scratch, scratch);
if (memcmp (scratch, plaintext, sizeof (plaintext)))
- log_fatal ("Twofish test decryption failed\n");
+ return "Twofish test decryption failed.";
+ return NULL;
}
/* More complete test program. This does a thousand encryptions and
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 60259ce4d..f5a694a8b 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,11 @@
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <[email protected]>
+
+ * textfilter.c (text_filter): Now uses iobuf_read_line().
+ (read_line): Removed.
+
+ * armor.c (trim_trailing_spaces): Removed and replaced
+ by trim_trailing_ws from libutil
+
Sat Jan 16 12:03:27 CET 1999 Werner Koch <[email protected]>
* hkp.c (hkp_ask_import): Use only the short keyid
diff --git a/g10/armor.c b/g10/armor.c
index 1f23c6f64..491cab4fa 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -256,31 +256,6 @@ parse_hash_header( const char *line )
-
-static unsigned
-trim_trailing_spaces( byte *line, unsigned len )
-{
- byte *p, *mark;
- unsigned n;
-
- for(mark=NULL, p=line, n=0; n < len; n++, p++ ) {
- if( strchr(" \t\r\n", *p ) ) {
- if( !mark )
- mark = p;
- }
- else
- mark = NULL;
- }
-
- if( mark ) {
- *mark = 0;
- return mark - line;
- }
- return len;
-}
-
-
-
/****************
* Check whether this is a armor line.
* returns: -1 if it is not a armor header or the index number of the
@@ -339,7 +314,7 @@ parse_header_line( armor_filter_context_t *afx, byte *line, unsigned len )
if( *line == '\n' || ( len && (*line == '\r' && line[1]=='\n') ) )
return 0; /* empty line */
- len = trim_trailing_spaces( line, len );
+ len = trim_trailing_ws( line, len );
p = strchr( line, ':');
if( !p || !p[1] ) {
log_error(_("invalid armor header: "));
@@ -521,8 +496,7 @@ fake_packet( armor_filter_context_t *afx, IOBUF a,
if( !maxlen )
afx->truncated++;
if( !afx->not_dash_escaped )
- afx->buffer_len = trim_trailing_spaces( afx->buffer,
- afx->buffer_len );
+ afx->buffer_len = trim_trailing_ws( afx->buffer, afx->buffer_len );
p = afx->buffer;
n = afx->buffer_len;
diff --git a/g10/filter.h b/g10/filter.h
index f0448f1bd..ebd58e370 100644
--- a/g10/filter.h
+++ b/g10/filter.h
@@ -80,10 +80,11 @@ typedef struct {
typedef struct {
- int eof;
- size_t idx;
- size_t len;
- byte buf[256];
+ byte *buffer; /* malloced buffer */
+ unsigned buffer_size; /* and size of this buffer */
+ unsigned buffer_len; /* used length of the buffer */
+ unsigned buffer_pos; /* read position */
+ int truncated; /* number of truncated lines */
} text_filter_context_t;
diff --git a/g10/free-packet.c b/g10/free-packet.c
index e953b0d45..78f81bd0a 100644
--- a/g10/free-packet.c
+++ b/g10/free-packet.c
@@ -444,6 +444,11 @@ cmp_signatures( PKT_signature *a, PKT_signature *b )
return 0;
}
+
+
+/****************
+ * Returns: true if the user ids do not match
+ */
int
cmp_user_ids( PKT_user_id *a, PKT_user_id *b )
{
diff --git a/g10/sign.c b/g10/sign.c
index b011043b2..e8582f43d 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -349,8 +349,6 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
* data, it is not possible to know the used length
* without a double read of the file - to avoid that
* we simple use partial length packets.
- * FIXME: We have to do the double read when opt.rfc1991
- * is active.
*/
if( opt.textmode && !outfile )
filesize = 0;
diff --git a/g10/textfilter.c b/g10/textfilter.c
index 9e820d159..9959c9335 100644
--- a/g10/textfilter.c
+++ b/g10/textfilter.c
@@ -30,72 +30,10 @@
#include "memory.h"
#include "util.h"
#include "filter.h"
+#include "i18n.h"
-
-
-static int
-read_line( byte *buf, size_t *r_buflen, IOBUF a )
-{
- int c;
- int rc = 0;
- byte *p;
- size_t buflen;
- int no_lf=0;
- size_t n;
-
- buflen = *r_buflen;
- assert(buflen >= 20 );
- buflen -= 3; /* leave some room for CR,LF and one extra */
-
- for(c=0, n=0; n < buflen && (c=iobuf_get(a)) != -1 && c != '\n'; )
- buf[n++] = c;
- buf[n] = 0;
- if( c == -1 ) {
- rc = -1;
- if( !n || buf[n-1] != '\n' )
- no_lf = 1;
- }
- else if( c != '\n' ) {
- IOBUF b = iobuf_temp();
- while( (c=iobuf_get(a)) != -1 && c != '\n' ) {
- iobuf_put(b,c);
- if( c != ' ' && c != '\t' && c != '\r' )
- break;
- }
- if( c == '\n' ) { /* okay we can skip the rest of the line */
- iobuf_close(b);
- }
- else {
- iobuf_unget_and_close_temp(a,b);
- no_lf = 1;
- }
- }
-
- if( !no_lf ) {
- /* append CR,LF after removing trailing wspaces */
- for(p=buf+n-1; n; n--, p-- ) {
- assert( *p != '\n' );
- if( *p != ' ' && *p != '\t' && *p != '\r' ) {
- p[1] = '\r';
- p[2] = '\n';
- n += 2;
- break;
- }
- }
- if( !n ) {
- buf[0] = '\r';
- buf[1] = '\n';
- n = 2;
- }
- }
-
-
- *r_buflen = n;
- return rc;
-}
-
-
+#define MAX_LINELEN 20000
/****************
@@ -109,33 +47,52 @@ text_filter( void *opaque, int control,
size_t size = *ret_len;
text_filter_context_t *tfx = opaque;
int rc=0;
- size_t len, n, nn;
if( control == IOBUFCTRL_UNDERFLOW ) {
- assert( size > 30 );
- len = 0;
+ size_t len = 0;
+ unsigned maxlen;
+
+ assert( size > 10 );
+ size -= 2; /* reserve 2 bytes to append CR,LF */
while( !rc && len < size ) {
- if( tfx->idx < tfx->len ) { /* flush the last buffer */
- n = tfx->len;
- for(nn=tfx->idx; len < size && nn < n ; nn++ )
- buf[len++] = tfx->buf[nn];
- tfx->idx = nn;
+ int lf_seen;
+
+ while( len < size && tfx->buffer_pos < tfx->buffer_len )
+ buf[len++] = tfx->buffer[tfx->buffer_pos++];
+ if( len >= size )
continue;
+
+ /* read the next line */
+ maxlen = MAX_LINELEN;
+ tfx->buffer_pos = 0;
+ tfx->buffer_len = iobuf_read_line( a, &tfx->buffer,
+ &tfx->buffer_size, &maxlen );
+ if( !maxlen )
+ tfx->truncated++;
+ if( !tfx->buffer_len ) {
+ if( !len )
+ rc = -1; /* eof */
+ break;
}
- if( tfx->eof ) {
- rc = -1;
- continue;
+ lf_seen = tfx->buffer[tfx->buffer_len-1] == '\n';
+ tfx->buffer_len = trim_trailing_ws( tfx->buffer, tfx->buffer_len );
+ if( lf_seen ) {
+ tfx->buffer[tfx->buffer_len++] = '\r';
+ tfx->buffer[tfx->buffer_len++] = '\n';
}
- n = DIM(tfx->buf);
- tfx->idx = 0;
- if( read_line( tfx->buf, &n, a ) == -1 )
- tfx->eof = 1;
- tfx->len = n;
}
+
*ret_len = len;
}
else if( control == IOBUFCTRL_DESC )
*(char**)buf = "text_filter";
+ else if( control == IOBUFCTRL_FREE ) {
+ if( tfx->truncated )
+ log_error(_("can't handle text lines longer than %d characters\n"),
+ MAX_LINELEN );
+ m_free( tfx->buffer );
+ tfx->buffer = NULL;
+ }
return rc;
}
diff --git a/include/errors.h b/include/errors.h
index 56dd14ada..32d1ea55e 100644
--- a/include/errors.h
+++ b/include/errors.h
@@ -69,6 +69,7 @@
#define G10ERR_INVALID_URI 47 /* e.g. unsupported scheme */
#define G10ERR_NETWORK 48 /* general network error */
#define G10ERR_UNKNOWN_HOST 49
+#define G10ERR_SELFTEST_FAILED 50
#ifndef HAVE_STRERROR
diff --git a/include/util.h b/include/util.h
index 892d508cc..8b8df37e8 100644
--- a/include/util.h
+++ b/include/util.h
@@ -161,6 +161,7 @@ STRLIST strlist_last( STRLIST node );
const char *memistr( const char *buf, size_t buflen, const char *sub );
char *mem2str( char *, const void *, size_t);
char *trim_spaces( char *string );
+unsigned trim_trailing_ws( byte *line, unsigned len );
int string_count_chr( const char *string, int c );
int set_native_charset( const char *newset );
char *native_to_utf8( const char *string );
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3fb020b0c..83e96710f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -35,6 +35,7 @@ g10/hkp.c
g10/seckey-cert.c
g10/sig-check.c
g10/sign.c
+g10/textfilter.c
g10/tdbio.c
g10/trustdb.c
g10/verify.c
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
index b3eaae7f3..9f2241b21 100644
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <[email protected]>
+
+ * autogen.sh: Now checks for installed gettext
+
Sat Jan 16 09:27:30 CET 1999 Werner Koch <[email protected]>
* config.guess (m68k-atari-mint): New.
diff --git a/scripts/autogen.sh b/scripts/autogen.sh
index cba5adcc1..813786c7f 100755
--- a/scripts/autogen.sh
+++ b/scripts/autogen.sh
@@ -35,6 +35,18 @@ else
DIE="yes"
fi
+
+if (gettext --version </dev/null 2>/dev/null | awk 'NR==1 { split($4,A,"\."); \
+ X=10000*A[1]+100*A[2]+A[3]; echo X; if( X >= 1035 ) exit 1; exit 0}')
+ then
+ echo "**Error**: You must have "\`gettext\'" installed to compile $PGM."
+ echo ' (version 0.10.35 or newer is required; get'
+ echo ' ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz)'
+ DIE="yes"
+fi
+
+
+
if test "$DIE" = "yes"; then
exit 1
fi
diff --git a/util/ChangeLog b/util/ChangeLog
index 39165bbe6..1f3a87a24 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <[email protected]>
+
+ * strgutil.c (trim_trailing_ws): New.
+
Sat Jan 16 12:03:27 CET 1999 Werner Koch <[email protected]>
* http.c (connect_server): Fixed stupid bug.
diff --git a/util/errors.c b/util/errors.c
index 003be82fd..3e9dbcf79 100644
--- a/util/errors.c
+++ b/util/errors.c
@@ -98,6 +98,7 @@ g10_errstr( int err )
X(BAD_URI ,N_("bad URI"))
X(INVALID_URI ,N_("unsupported URI"))
X(NETWORK ,N_("network error"))
+ X(SELFTEST_FAILED,"selftest failed")
default: p = buf; sprintf(buf, "g10err=%d", err); break;
}
#undef X
diff --git a/util/strgutil.c b/util/strgutil.c
index d5379f903..b3213dc9c 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -191,6 +191,34 @@ trim_spaces( char *str )
}
+
+/****************
+ * remove trailing white spaces and return the length of the buffer
+ */
+unsigned
+trim_trailing_ws( byte *line, unsigned len )
+{
+ byte *p, *mark;
+ unsigned n;
+
+ for(mark=NULL, p=line, n=0; n < len; n++, p++ ) {
+ if( strchr(" \t\r\n", *p ) ) {
+ if( !mark )
+ mark = p;
+ }
+ else
+ mark = NULL;
+ }
+
+ if( mark ) {
+ *mark = 0;
+ return mark - line;
+ }
+ return len;
+}
+
+
+
int
string_count_chr( const char *string, int c )
{