removed trailing whitespace, free a missing malloc when returning error

This commit is contained in:
Daniel Stenberg 2004-06-30 11:51:24 +00:00
parent 4af08a19f8
commit 6c3759d78d
1 changed files with 40 additions and 38 deletions

View File

@ -10,22 +10,22 @@
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -75,7 +75,7 @@ static struct {
{ prot_private, "private" }
};
static enum protection_level
static enum protection_level
name_to_level(const char *name)
{
int i;
@ -146,7 +146,7 @@ sec_get_data(struct connectdata *conn,
{
int len;
int b;
b = block_read(fd, &len, sizeof(len));
if (b == 0)
return 0;
@ -206,12 +206,12 @@ Curl_sec_read(struct connectdata *conn, int fd, void *buffer, int length)
conn->in_buffer.eof_flag = 0;
return 0;
}
len = buffer_read(&conn->in_buffer, buffer, length);
length -= len;
rx += len;
buffer = (char*)buffer + len;
while(length) {
if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
return -1;
@ -261,7 +261,7 @@ Curl_sec_write(struct connectdata *conn, int fd, char *buffer, int length)
{
int len = conn->buffer_size;
int tx = 0;
if(conn->data_prot == prot_clear)
return write(fd, buffer, length);
@ -283,7 +283,7 @@ Curl_sec_putc(struct connectdata *conn, int c, FILE *F)
char ch = c;
if(conn->data_prot == prot_clear)
return putc(c, F);
buffer_write(&conn->out_buffer, &ch, 1);
if(c == '\n' || conn->out_buffer.index >= 1024 /* XXX */) {
Curl_sec_write(conn, fileno(F), conn->out_buffer.data,
@ -296,36 +296,38 @@ Curl_sec_putc(struct connectdata *conn, int c, FILE *F)
int
Curl_sec_read_msg(struct connectdata *conn, char *s, int level)
{
int len;
char *buf;
int code;
buf = malloc(strlen(s));
len = Curl_base64_decode(s + 4, buf); /* XXX */
len = (conn->mech->decode)(conn->app_data, buf, len, level, conn);
if(len < 0)
return -1;
buf[len] = '\0';
int len;
char *buf;
int code;
if(buf[3] == '-')
code = 0;
else
sscanf(buf, "%d", &code);
if(buf[len-1] == '\n')
buf[len-1] = '\0';
strcpy(s, buf);
buf = malloc(strlen(s));
len = Curl_base64_decode(s + 4, buf); /* XXX */
len = (conn->mech->decode)(conn->app_data, buf, len, level, conn);
if(len < 0) {
free(buf);
return code;
return -1;
}
buf[len] = '\0';
if(buf[3] == '-')
code = 0;
else
sscanf(buf, "%d", &code);
if(buf[len-1] == '\n')
buf[len-1] = '\0';
strcpy(s, buf);
free(buf);
return code;
}
enum protection_level
Curl_set_command_prot(struct connectdata *conn, enum protection_level level)
{
enum protection_level old = conn->command_prot;
conn->command_prot = level;
return old;
enum protection_level old = conn->command_prot;
conn->command_prot = level;
return old;
}
static int
@ -371,7 +373,7 @@ sec_prot_internal(struct connectdata *conn, int level)
failf(conn->data, "Failed to set protection level.");
return -1;
}
conn->data_prot = (enum protection_level)level;
return 0;
}
@ -412,7 +414,7 @@ Curl_sec_login(struct connectdata *conn)
return -1;
}
conn->app_data = tmp;
if((*m)->init && (*(*m)->init)(conn->app_data) != 0) {
infof(data, "Skipping %s...\n", (*m)->name);
continue;
@ -446,7 +448,7 @@ Curl_sec_login(struct connectdata *conn)
}
ret = (*(*m)->auth)(conn->app_data, conn);
if(ret == AUTH_CONTINUE)
continue;
else if(ret != AUTH_OK){
@ -458,7 +460,7 @@ Curl_sec_login(struct connectdata *conn)
conn->command_prot = prot_safe;
break;
}
return *m == NULL;
}