diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-10-05 13:34:20 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-10-05 13:34:20 (GMT) |
commit | 609801fe67c95f9959468df8316a8f4a26943842 (patch) | |
tree | be2cf804edae61b76806c95bf0965985e4f45aed /Source/CTest/Curl/security.c | |
parent | 50da0328472ad0f318f64a20876c474ad968fef3 (diff) | |
download | CMake-609801fe67c95f9959468df8316a8f4a26943842.zip CMake-609801fe67c95f9959468df8316a8f4a26943842.tar.gz CMake-609801fe67c95f9959468df8316a8f4a26943842.tar.bz2 |
ENH: Update Curl to 7.12.1
Diffstat (limited to 'Source/CTest/Curl/security.c')
-rw-r--r-- | Source/CTest/Curl/security.c | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/Source/CTest/Curl/security.c b/Source/CTest/Curl/security.c index c8f3c22..3b2a392 100644 --- a/Source/CTest/Curl/security.c +++ b/Source/CTest/Curl/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 @@ -41,7 +41,7 @@ #include "setup.h" #ifndef CURL_DISABLE_FTP -#ifdef KRB4 +#ifdef HAVE_KRB4 #define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */ #include <curl/mprintf.h> @@ -58,11 +58,10 @@ #include "base64.h" #include "sendf.h" #include "ftp.h" +#include "memory.h" /* The last #include file should be: */ -#ifdef MALLOCDEBUG #include "memdebug.h" -#endif #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -76,7 +75,7 @@ static struct { { prot_private, "private" } }; -static enum protection_level +static enum protection_level name_to_level(const char *name) { int i; @@ -90,7 +89,7 @@ static struct Curl_sec_client_mech *mechs[] = { #ifdef KRB5 /* not supported */ #endif -#ifdef KRB4 +#ifdef HAVE_KRB4 &Curl_krb4_client_mech, #endif NULL @@ -147,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; @@ -207,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; @@ -262,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); @@ -284,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, @@ -297,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 @@ -372,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; } @@ -413,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; @@ -447,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){ @@ -459,7 +460,7 @@ Curl_sec_login(struct connectdata *conn) conn->command_prot = prot_safe; break; } - + return *m == NULL; } @@ -478,13 +479,5 @@ Curl_sec_end(struct connectdata *conn) conn->mech=NULL; } -#endif /* KRB4 */ +#endif /* HAVE_KRB4 */ #endif /* CURL_DISABLE_FTP */ - -/* - * local variables: - * eval: (load-file "../curl-mode.el") - * end: - * vim600: fdm=marker - * vim: et sw=2 ts=2 sts=2 tw=78 - */ |