Commit 06524719 authored by Niels Möller's avatar Niels Möller

Minor bugfixes to get the code (including the new charset.c file) to compile.

Rev: src/Makefile.in:1.17
Rev: src/alist.c:1.5
Rev: src/charset.c:1.2
Rev: src/charset.h:1.2
Rev: src/crypto.c:1.8
Rev: src/keyexchange.c:1.19
Rev: src/keyexchange.h:1.18
Rev: src/parse.c:1.15
Rev: src/read_packet.c:1.22
Rev: src/service.h:1.3
Rev: src/werror.c:1.12
parent 359242cd
......@@ -34,7 +34,7 @@ binprefix =
LOADLIBES = $(LIBS) lib/algorithms.a
COMMON_SRCS = alist.c atoms.c bignum.c connection.c crypto.c \
COMMON_SRCS = alist.c atoms.c bignum.c charset.c connection.c crypto.c \
debug.c disconnect.c encrypt.c format.c getopt.c io.c keyexchange.c \
packet_ignore.c pad.c parse.c publickey_crypto.c \
randomness.c \
......
......@@ -41,30 +41,30 @@ struct alist_linear
static void *do_linear_get(struct alist *c, int atom)
{
struct alist_linear *closure = (struct alist_linear *) c;
struct alist_linear *self = (struct alist_linear *) c;
assert(atom >= 0);
assert(atom < NUMBER_OF_ATOMS);
MDEBUG(closure);
MDEBUG(self);
return closure->table[atom];
return self->table[atom];
}
static void do_linear_set(struct alist *c, int atom, void *value)
{
struct alist_linear *closure = (struct alist_linear *) c;
struct alist_linear *self = (struct alist_linear *) c;
assert(atom >= 0);
assert(atom < NUMBER_OF_ATOMS);
MDEBUG(closure);
MDEBUG(self);
#if ALIST_USE_SIZE
size += !closure->table[atom] - !value;
size += !self->table[atom] - !value;
#endif
closure->table[atom] = value;
self->table[atom] = value;
}
struct alist *make_linear_alist(int n, ...)
......@@ -119,15 +119,15 @@ struct alist_linked
static void *do_linked_get(struct alist *c, int atom)
{
struct alist_linked *closure = (struct alist_linked *) c;
struct alist_linked *self = (struct alist_linked *) c;
struct node *p;
assert(atom >= 0);
assert(atom < NUMBER_OF_ATOMS);
MDEBUG(closure);
MDEBUG(self);
for (p = self->first; p; p = p->next)
for (p = self->head; p; p = p->next)
if (p->atom == atom)
return p->value;
......@@ -136,18 +136,18 @@ static void *do_linked_get(struct alist *c, int atom)
static void do_linked_set(struct alist *c, int atom, void *value)
{
struct alist_linked *closure = (struct alist_linked *) c;
struct alist_linked *self = (struct alist_linked *) c;
assert(atom >= 0);
assert(atom < NUMBER_OF_ATOMS);
MDEBUG(closure);
MDEBUG(self);
if (value)
{
struct node *p;
for (p = self->first; p; p = p->next)
for (p = self->head; p; p = p->next)
if (p->atom == atom)
{
p->value = value;
......@@ -155,11 +155,11 @@ static void do_linked_set(struct alist *c, int atom, void *value)
}
p = xalloc(sizeof(struct node));
p->next = self->first;
p->next = self->head;
p->atom = atom;
p->value = value;
self->first = p;
self->head = p;
#if ALIST_USE_SIZE
self->size++;
#endif
......@@ -168,15 +168,17 @@ static void do_linked_set(struct alist *c, int atom, void *value)
{ /* Remove atom */
struct node **p;
for(p = &self->first; *p; )
for(p = &self->head; *p; )
{
struct node *o = *p;
if (o->atom = atom)
if (o->atom == atom)
{
*p = o->next;
lsh_free(o);
#if ALIST_USE_SIZE
self->size--;
#endif
return;
}
p = &o->next;
......@@ -192,12 +194,14 @@ struct alist *make_linked_alist(int n, ...)
struct alist_linked *self = xalloc(sizeof(struct alist_linked));
struct alist *res = &self->super;
struct node *p;
#if ALIST_USE_SIZE
self->size = 0;
#endif
self->first = NULL;
self->head = NULL;
va_start(args, n);
......
......@@ -26,6 +26,10 @@
#include "charset.h"
#include "parse.h"
#include "werror.h"
#include "xalloc.h"
#include <assert.h>
static int local_charset;
......@@ -39,7 +43,7 @@ UINT32 local_to_ucs4(int c)
{
switch (local_charset)
{
case CHARSET_US_ASCII:
case CHARSET_USASCII:
case CHARSET_LATIN1:
return (UINT32) c;
default:
......@@ -52,7 +56,7 @@ int ucs4_to_local(UINT32 c)
{
switch (local_charset)
{
case CHARSET_US_ASCII:
case CHARSET_USASCII:
return (c < 0x80) ? c : -1;
case CHARSET_LATIN1:
return (c < 0x100) ? c : -1;
......@@ -61,7 +65,7 @@ int ucs4_to_local(UINT32 c)
};
}
struct lsh_string *local_to_utf8(struct lsh_string s, int free)
struct lsh_string *local_to_utf8(struct lsh_string *s, int free)
{
switch (local_charset)
{
......@@ -108,13 +112,13 @@ struct lsh_string *local_to_utf8(struct lsh_string s, int free)
}
}
{
struct lsh_string res = lsh_string_alloc(total);
struct lsh_string *res = lsh_string_alloc(total);
int i, j;
for(i = j = 0; i<s->length; i++)
{
static const UINT8 *prefix
= {0, 0xC0, 0xE0, 0xF0, 0xF8, 0xFc };
static const UINT8 prefix[]
= {0, 0xC0, 0xE0, 0xF0, 0xF8, 0XFC };
UINT32 c = chars[i];
unsigned char l = lengths[i] - 1;
......@@ -142,7 +146,7 @@ struct lsh_string *local_to_utf8(struct lsh_string s, int free)
}
struct lsh_string *utf8_to_local(struct lsh_string s, int free)
struct lsh_string *utf8_to_local(struct lsh_string *s, int free)
{
int i;
struct lsh_string *res;
......
......@@ -40,7 +40,7 @@ void set_local_charset(int charset);
UINT32 local_to_ucs4(int c);
int ucs4_to_local(UINT32 c);
struct lsh_string *local_to_utf8(struct lsh_string s, int free);
struct lsh_string *utf8_to_local(struct lsh_string s, int free);
struct lsh_string *local_to_utf8(struct lsh_string *s, int free);
struct lsh_string *utf8_to_local(struct lsh_string *s, int free);
#endif /* LSH_CHARSET_H_INCLUDED */
......@@ -23,6 +23,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string.h>
#include <sys/types.h>
#include <time.h>
......
......@@ -50,6 +50,8 @@ struct kexinit_handler
* and therefore the remote side can't screw things up. */
struct alist *algorithms;
struct ssh_service *finished;
};
#define NLISTS 10
......@@ -276,6 +278,7 @@ static int do_handle_kexinit(struct packet_handler *c,
return KEYEXCHANGE_INIT( (struct keyexchange_algorithm *)
ALIST_GET(closure->algorithms, kex_algorithm),
connection,
closure->finished,
hostkey_algorithm,
ALIST_GET(closure->algorithms, hostkey_algorithm),
algorithms);
......
......@@ -75,7 +75,7 @@ struct keyexchange_algorithm
int (*init)(struct keyexchange_algorithm *closure,
struct ssh_connection *connection,
struct ssh_service *finished;
struct ssh_service *finished,
int hostkey_algorithm_atom,
struct signature_algorithm *hostkey_algorithm,
void **algorithms);
......
......@@ -149,7 +149,7 @@ int parse_utf8(struct simple_buffer *buffer, UINT32 *result)
length = 4;
*result = first & 0x07;
break;
case 8: case 0xA;
case 8: case 0xA:
length = 5;
*result = first & 0x03;
break;
......
......@@ -222,7 +222,7 @@ static int do_read_packet(struct read_handler **h,
{
UINT32 left
= ( (closure->buffer->length + closure->buffer->data)
- closure->crypt_pos) );
- closure->crypt_pos );
if (closure->connection->rec_crypto)
CRYPT(closure->connection->rec_crypto,
left,
......
......@@ -31,7 +31,7 @@
/* The init function only returns 1 on success, 0 on failure. */
struct ssh_service
{
int (init *)(struct ssh_service *self, struct ssh_connection *c);
int (*init)(struct ssh_service *self, struct ssh_connection *c);
};
#define SERVICE_INIT(s, c) ((s)->init((s), (c)))
......
......@@ -26,6 +26,7 @@
#include "werror.h"
#include "charset.h"
#include "parse.h"
#include <stdio.h>
#include <stdarg.h>
......@@ -125,8 +126,8 @@ void verbose_safe(UINT32 length, UINT8 *msg)
static void write_utf8(UINT32 length, UINT8 *msg)
{
struct simple_buffer buffer;
simple_buffer_init(&buffer, lengthm msg);
simple_buffer_init(&buffer, length, msg);
while(1)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment