diff options
author | Werner Koch <wk@gnupg.org> | 2002-01-10 20:46:04 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2002-01-10 20:46:04 +0100 |
commit | 489207db377d9b3c192cbcf437b0ea0c68c41d61 (patch) | |
tree | 519b09873ed74dfad73eb4ac55b3300f4d9f1ec4 /assuan | |
parent | * genkey.c: Store the secret part and return the public part. (diff) | |
download | gnupg2-489207db377d9b3c192cbcf437b0ea0c68c41d61.tar.xz gnupg2-489207db377d9b3c192cbcf437b0ea0c68c41d61.zip |
* assuan-handler.c (assuan_set_okay_line): New.
(process_request): And use it here.
Diffstat (limited to 'assuan')
-rw-r--r-- | assuan/ChangeLog | 13 | ||||
-rw-r--r-- | assuan/assuan-defs.h | 1 | ||||
-rw-r--r-- | assuan/assuan-handler.c | 36 | ||||
-rw-r--r-- | assuan/assuan-inquire.c | 9 | ||||
-rw-r--r-- | assuan/assuan-pipe-server.c | 1 | ||||
-rw-r--r-- | assuan/assuan.h | 1 |
6 files changed, 56 insertions, 5 deletions
diff --git a/assuan/ChangeLog b/assuan/ChangeLog index dbf5f43ea..e79c2ba14 100644 --- a/assuan/ChangeLog +++ b/assuan/ChangeLog @@ -1,3 +1,14 @@ +2002-01-03 Werner Koch <wk@gnupg.org> + + * assuan-handler.c (assuan_set_okay_line): New. + (process_request): And use it here. + +2002-01-02 Werner Koch <wk@gnupg.org> + + * assuan-inquire.c (init_membuf,put_membuf,get_membuf): Apply a + hidden 0 behind the buffer so that the buffer can be used as a + string in certain contexts. + 2001-12-14 Marcus Brinkmann <marcus@g10code.de> * assuan-connect.c (assuan_pipe_connect): New argument @@ -90,7 +101,7 @@ * You may find it source-copied in other packages. * *********************************************************** - Copyright 2001 Free Software Foundation, Inc. + Copyright 2001, 2002 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without diff --git a/assuan/assuan-defs.h b/assuan/assuan-defs.h index ecabd3828..07f56e32e 100644 --- a/assuan/assuan-defs.h +++ b/assuan/assuan-defs.h @@ -39,6 +39,7 @@ struct assuan_context_s { int is_server; /* set if this is context belongs to a server */ int in_inquire; char *hello_line; + char *okay_line; /* see assan_set_okay_line() */ void *user_pointer; /* for assuan_[gs]et_pointer () */ diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c index a82bd5379..ce7476a6a 100644 --- a/assuan/assuan-handler.c +++ b/assuan/assuan-handler.c @@ -382,7 +382,7 @@ process_request (ASSUAN_CONTEXT ctx) /* Error handling */ if (!rc) { - rc = assuan_write_line (ctx, "OK"); + rc = assuan_write_line (ctx, ctx->okay_line? ctx->okay_line : "OK"); } else if (rc == -1) { /* No error checking because the peer may have already disconnect */ @@ -405,6 +405,11 @@ process_request (ASSUAN_CONTEXT ctx) rc = assuan_write_line (ctx, errline); } + if (ctx->okay_line) + { + xfree (ctx->okay_line); + ctx->okay_line = NULL; + } return rc; } @@ -522,6 +527,35 @@ assuan_get_data_fp (ASSUAN_CONTEXT ctx) } +/* Set the text used for the next OK reponse. This string is + automatically reset to NULL after the next command. */ +AssuanError +assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + if (!line) + { + xfree (ctx->okay_line); + ctx->okay_line = NULL; + } + else + { + /* FIXME: we need to use gcry_is_secure() to test whether + we should allocate the entire line in secure memory */ + char *buf = xtrymalloc (3+strlen(line)+1); + if (!buf) + return ASSUAN_Out_Of_Core; + strcpy (buf, "OK "); + strcpy (buf+3, line); + xfree (ctx->okay_line); + ctx->okay_line = buf; + } + return 0; +} + + + void assuan_write_status (ASSUAN_CONTEXT ctx, const char *keyword, const char *text) { diff --git a/assuan/assuan-inquire.c b/assuan/assuan-inquire.c index 8fec77ef8..933091e15 100644 --- a/assuan/assuan-inquire.c +++ b/assuan/assuan-inquire.c @@ -1,5 +1,5 @@ /* assuan-inquire.c - handle inquire stuff - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -56,7 +56,8 @@ init_membuf (struct membuf *mb, int initiallen, size_t maxlen) mb->out_of_core = 0; mb->too_large = 0; mb->maxlen = maxlen; - mb->buf = xtrymalloc (initiallen); + /* we need to allocate one byte more for get_membuf */ + mb->buf = xtrymalloc (initiallen+1); if (!mb->buf) mb->out_of_core = 1; } @@ -78,7 +79,8 @@ put_membuf (struct membuf *mb, const void *buf, size_t len) char *p; mb->size += len + 1024; - p = xtryrealloc (mb->buf, mb->size); + /* we need to allocate one byte more for get_membuf */ + p = xtryrealloc (mb->buf, mb->size+1); if (!p) { mb->out_of_core = 1; @@ -102,6 +104,7 @@ get_membuf (struct membuf *mb, size_t *len) return NULL; } + mb->buf[mb->len] = 0; /* there is enough space for the hidden eos */ p = mb->buf; *len = mb->len; mb->buf = NULL; diff --git a/assuan/assuan-pipe-server.c b/assuan/assuan-pipe-server.c index 2a9b829aa..58f981a09 100644 --- a/assuan/assuan-pipe-server.c +++ b/assuan/assuan-pipe-server.c @@ -58,6 +58,7 @@ assuan_deinit_pipe_server (ASSUAN_CONTEXT ctx) if (ctx) { xfree (ctx->hello_line); + xfree (ctx->okay_line); xfree (ctx); } } diff --git a/assuan/assuan.h b/assuan/assuan.h index cddc98cb4..12f80ca35 100644 --- a/assuan/assuan.h +++ b/assuan/assuan.h @@ -127,6 +127,7 @@ int assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what, FILE *assuan_get_data_fp (ASSUAN_CONTEXT ctx); +AssuanError assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line); void assuan_write_status (ASSUAN_CONTEXT ctx, const char *keyword, const char *text); |