summaryrefslogtreecommitdiff
path: root/lib/security.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-06-30 11:51:24 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-06-30 11:51:24 +0000
commit6c3759d78d885d3675094671a8bde9ff41c9a8cc (patch)
tree47841e696898cabefc62bca37a5574d7906e05c0 /lib/security.c
parent4af08a19f85c577d9b1f2df892c82e34e473f31d (diff)
downloadcurl-6c3759d78d885d3675094671a8bde9ff41c9a8cc.tar.gz
removed trailing whitespace, free a missing malloc when returning error
Diffstat (limited to 'lib/security.c')
-rw-r--r--lib/security.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/lib/security.c b/lib/security.c
index f1af44201..41dfa7311 100644
--- a/lib/security.c
+++ b/lib/security.c
@@ -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';
-
- if(buf[3] == '-')
- code = 0;
- else
- sscanf(buf, "%d", &code);
- if(buf[len-1] == '\n')
- buf[len-1] = '\0';
- strcpy(s, buf);
+ 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) {
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;
}