~ubuntu-branches/ubuntu/intrepid/curl/intrepid-security

« back to all changes in this revision

Viewing changes to lib/dict.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-02-08 11:20:41 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080208112041-lhq5g4aa7i1wc4va
Tags: 7.18.0-1ubuntu1
* Merge from Debian; remaining changes:
  - Drop the stunnel build dependency.
  - Drop the build-dependency on libdb4.5-dev, add build-dependency on
    openssh-server.
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: dict.c,v 1.52 2007-10-17 16:58:32 yangtse Exp $
 
21
 * $Id: dict.c,v 1.55 2007-12-08 22:50:55 bagder Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
87
87
 * Forward declarations.
88
88
 */
89
89
 
90
 
static CURLcode Curl_dict(struct connectdata *conn, bool *done);
 
90
static CURLcode dict_do(struct connectdata *conn, bool *done);
91
91
 
92
92
/*
93
93
 * DICT protocol handler.
96
96
const struct Curl_handler Curl_handler_dict = {
97
97
  "DICT",                               /* scheme */
98
98
  ZERO_NULL,                            /* setup_connection */
99
 
  Curl_dict,                            /* do_it */
 
99
  dict_do,                              /* do_it */
100
100
  ZERO_NULL,                            /* done */
101
101
  ZERO_NULL,                            /* do_more */
102
102
  ZERO_NULL,                            /* connect_it */
129
129
    for(ptr = newp;
130
130
        (byte = *ptr) != 0;
131
131
        ptr++) {
132
 
      if ((byte <= 32) || (byte == 127) ||
 
132
      if((byte <= 32) || (byte == 127) ||
133
133
          (byte == '\'') || (byte == '\"') || (byte == '\\')) {
134
134
        dictp[olen++] = '\\';
135
135
      }
142
142
  return dictp;
143
143
}
144
144
 
145
 
static CURLcode Curl_dict(struct connectdata *conn, bool *done)
 
145
static CURLcode dict_do(struct connectdata *conn, bool *done)
146
146
{
147
147
  char *word;
148
148
  char *eword;
155
155
  struct SessionHandle *data=conn->data;
156
156
  curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
157
157
 
158
 
  char *path = data->reqdata.path;
159
 
  curl_off_t *bytecount = &data->reqdata.keep.bytecount;
 
158
  char *path = data->state.path;
 
159
  curl_off_t *bytecount = &data->req.bytecount;
160
160
 
161
161
  *done = TRUE; /* unconditionally */
162
162
 
164
164
    /* AUTH is missing */
165
165
  }
166
166
 
167
 
  if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
 
167
  if(strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
168
168
      strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
169
169
      strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
170
170
 
171
171
    word = strchr(path, ':');
172
 
    if (word) {
 
172
    if(word) {
173
173
      word++;
174
174
      database = strchr(word, ':');
175
 
      if (database) {
 
175
      if(database) {
176
176
        *database++ = (char)0;
177
177
        strategy = strchr(database, ':');
178
 
        if (strategy) {
 
178
        if(strategy) {
179
179
          *strategy++ = (char)0;
180
180
          nthdef = strchr(strategy, ':');
181
 
          if (nthdef) {
 
181
          if(nthdef) {
182
182
            *nthdef++ = (char)0;
183
183
          }
184
184
        }
185
185
      }
186
186
    }
187
187
 
188
 
    if ((word == NULL) || (*word == (char)0)) {
 
188
    if((word == NULL) || (*word == (char)0)) {
189
189
      infof(data, "lookup word is missing");
190
190
      word=(char *)"default";
191
191
    }
192
 
    if ((database == NULL) || (*database == (char)0)) {
 
192
    if((database == NULL) || (*database == (char)0)) {
193
193
      database = (char *)"!";
194
194
    }
195
 
    if ((strategy == NULL) || (*strategy == (char)0)) {
 
195
    if((strategy == NULL) || (*strategy == (char)0)) {
196
196
      strategy = (char *)".";
197
197
    }
198
198
 
223
223
    if(result)
224
224
      return result;
225
225
  }
226
 
  else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
 
226
  else if(strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
227
227
           strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
228
228
           strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
229
229
 
230
230
    word = strchr(path, ':');
231
 
    if (word) {
 
231
    if(word) {
232
232
      word++;
233
233
      database = strchr(word, ':');
234
 
      if (database) {
 
234
      if(database) {
235
235
        *database++ = (char)0;
236
236
        nthdef = strchr(database, ':');
237
 
        if (nthdef) {
 
237
        if(nthdef) {
238
238
          *nthdef++ = (char)0;
239
239
        }
240
240
      }
241
241
    }
242
242
 
243
 
    if ((word == NULL) || (*word == (char)0)) {
 
243
    if((word == NULL) || (*word == (char)0)) {
244
244
      infof(data, "lookup word is missing");
245
245
      word=(char *)"default";
246
246
    }
247
 
    if ((database == NULL) || (*database == (char)0)) {
 
247
    if((database == NULL) || (*database == (char)0)) {
248
248
      database = (char *)"!";
249
249
    }
250
250
 
276
276
  else {
277
277
 
278
278
    ppath = strchr(path, '/');
279
 
    if (ppath) {
 
279
    if(ppath) {
280
280
      int i;
281
281
 
282
282
      ppath++;
283
283
      for (i = 0; ppath[i]; i++) {
284
 
        if (ppath[i] == ':')
 
284
        if(ppath[i] == ':')
285
285
          ppath[i] = ' ';
286
286
      }
287
287
      result = Curl_sendf(sockfd, conn,