diff options
| author | Peter Wemm <peter@FreeBSD.org> | 2018-10-08 08:12:28 +0000 |
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 2018-10-08 08:12:28 +0000 |
| commit | 110aebf74b4205a3ac01c7b59c1fb4145a1698a5 (patch) | |
| tree | 61f50de69fb3a4a952c5b5a43085d688e38207da /buckets | |
| parent | e52054a87e280687f7c530f9ecdcb93297ff4c71 (diff) | |
Vendor import serf-1.3.9 (now Apache serf)vendor/serf/serf-1.3.9vendor/serf
Notes
svn path=/vendor/serf/dist/; revision=339226
svn path=/vendor/serf/serf-1.3.9/; revision=339227; tag=vendor/serf/serf-1.3.9
Diffstat (limited to 'buckets')
| -rw-r--r-- | buckets/aggregate_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/allocator.c | 27 | ||||
| -rw-r--r-- | buckets/barrier_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/buckets.c | 27 | ||||
| -rw-r--r-- | buckets/bwtp_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/chunk_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/dechunk_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/deflate_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/file_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/headers_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/iovec_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/limit_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/mmap_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/request_buckets.c | 43 | ||||
| -rw-r--r-- | buckets/response_body_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/response_buckets.c | 39 | ||||
| -rw-r--r-- | buckets/simple_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/socket_buckets.c | 27 | ||||
| -rw-r--r-- | buckets/ssl_buckets.c | 173 |
19 files changed, 444 insertions, 243 deletions
diff --git a/buckets/aggregate_buckets.c b/buckets/aggregate_buckets.c index 2ae3fd538b96..952c7d41d805 100644 --- a/buckets/aggregate_buckets.c +++ b/buckets/aggregate_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include "serf.h" diff --git a/buckets/allocator.c b/buckets/allocator.c index 108167e016ca..bb02f45adef0 100644 --- a/buckets/allocator.c +++ b/buckets/allocator.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <stdlib.h> diff --git a/buckets/barrier_buckets.c b/buckets/barrier_buckets.c index eb410eea3591..86b89840d17d 100644 --- a/buckets/barrier_buckets.c +++ b/buckets/barrier_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/buckets.c b/buckets/buckets.c index 88e256b8c7fd..c8b597ad4102 100644 --- a/buckets/buckets.c +++ b/buckets/buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/bwtp_buckets.c b/buckets/bwtp_buckets.c index 7ef3047df2ce..37e774f5458f 100644 --- a/buckets/bwtp_buckets.c +++ b/buckets/bwtp_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/chunk_buckets.c b/buckets/chunk_buckets.c index 7f255088e662..6e590676e446 100644 --- a/buckets/chunk_buckets.c +++ b/buckets/chunk_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/dechunk_buckets.c b/buckets/dechunk_buckets.c index eda1e22642a3..1a2772008bdf 100644 --- a/buckets/dechunk_buckets.c +++ b/buckets/dechunk_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_strings.h> diff --git a/buckets/deflate_buckets.c b/buckets/deflate_buckets.c index 348d70d993dc..6d432562d645 100644 --- a/buckets/deflate_buckets.c +++ b/buckets/deflate_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_strings.h> diff --git a/buckets/file_buckets.c b/buckets/file_buckets.c index bd41cabfe507..364cb1c98e2b 100644 --- a/buckets/file_buckets.c +++ b/buckets/file_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/headers_buckets.c b/buckets/headers_buckets.c index 04e64d19b63b..35bf0536576c 100644 --- a/buckets/headers_buckets.c +++ b/buckets/headers_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <stdlib.h> diff --git a/buckets/iovec_buckets.c b/buckets/iovec_buckets.c index 9ac1d8d17941..d31e622089c7 100644 --- a/buckets/iovec_buckets.c +++ b/buckets/iovec_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2011 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/limit_buckets.c b/buckets/limit_buckets.c index 70b7efb3d620..95c4fb1eca47 100644 --- a/buckets/limit_buckets.c +++ b/buckets/limit_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/mmap_buckets.c b/buckets/mmap_buckets.c index c96bce43fc61..bfa82083943e 100644 --- a/buckets/mmap_buckets.c +++ b/buckets/mmap_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/request_buckets.c b/buckets/request_buckets.c index 912da8ad6df7..8d1a963efc0d 100644 --- a/buckets/request_buckets.c +++ b/buckets/request_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> @@ -190,6 +195,20 @@ static apr_status_t serf_request_peek(serf_bucket_t *bucket, return serf_bucket_peek(bucket, data, len); } +/* Note that this function is only called when serialize_data() + hasn't been called on the bucket */ +static void serf_request_destroy(serf_bucket_t *bucket) +{ + request_context_t *ctx = bucket->data; + + serf_bucket_destroy(ctx->headers); + + if (ctx->body) + serf_bucket_destroy(ctx->body); + + serf_default_destroy_and_data(bucket); +} + void serf_bucket_request_become( serf_bucket_t *bucket, const char *method, @@ -218,6 +237,6 @@ const serf_bucket_type_t serf_bucket_type_request = { serf_default_read_for_sendfile, serf_default_read_bucket, serf_request_peek, - serf_default_destroy_and_data, + serf_request_destroy, }; diff --git a/buckets/response_body_buckets.c b/buckets/response_body_buckets.c index c9648a69f6da..3e18c07df0e5 100644 --- a/buckets/response_body_buckets.c +++ b/buckets/response_body_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/response_buckets.c b/buckets/response_buckets.c index 39518bbd856e..eb72ef9906f6 100644 --- a/buckets/response_buckets.c +++ b/buckets/response_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_lib.h> @@ -128,7 +133,17 @@ static apr_status_t parse_status_line(response_context_t *ctx, int res; char *reason; /* ### stupid APR interface makes this non-const */ - /* ctx->linebuf.line should be of form: HTTP/1.1 200 OK */ + /* Ensure a valid length, to avoid overflow on the final '\0' */ + if (ctx->linebuf.used >= SERF_LINEBUF_LIMIT) { + return SERF_ERROR_BAD_HTTP_RESPONSE; + } + + /* apr_date_checkmask assumes its arguments are valid C strings */ + ctx->linebuf.line[ctx->linebuf.used] = '\0'; + + /* ctx->linebuf.line should be of form: 'HTTP/1.1 200 OK', + but we also explicitly allow the forms 'HTTP/1.1 200' (no reason) + and 'HTTP/1.1 401.1 Logon failed' (iis extended error codes) */ res = apr_date_checkmask(ctx->linebuf.line, "HTTP/#.# ###*"); if (!res) { /* Not an HTTP response? Well, at least we won't understand it. */ diff --git a/buckets/simple_buckets.c b/buckets/simple_buckets.c index 7ce7aeb25fd1..656e082c41de 100644 --- a/buckets/simple_buckets.c +++ b/buckets/simple_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/socket_buckets.c b/buckets/socket_buckets.c index d0facdab0daf..25dc07b54d81 100644 --- a/buckets/socket_buckets.c +++ b/buckets/socket_buckets.c @@ -1,16 +1,21 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== */ #include <apr_pools.h> diff --git a/buckets/ssl_buckets.c b/buckets/ssl_buckets.c index 579814ec81ac..b01e5359db08 100644 --- a/buckets/ssl_buckets.c +++ b/buckets/ssl_buckets.c @@ -1,36 +1,24 @@ -/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein +/* ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== * * ---- * - * For the OpenSSL thread-safety locking code: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * * Originally developed by Aaron Bannert and Justin Erenkrantz, eBuilt. */ @@ -64,6 +52,10 @@ #define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary))) #endif +#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L +#define USE_OPENSSL_1_1_API +#endif + /* * Here's an overview of the SSL bucket's relationship to OpenSSL and serf. @@ -152,6 +144,7 @@ struct serf_ssl_context_t { SSL_CTX *ctx; SSL *ssl; BIO *bio; + BIO_METHOD *biom; serf_ssl_stream_t encrypt; serf_ssl_stream_t decrypt; @@ -244,10 +237,28 @@ apps_ssl_info_callback(const SSL *s, int where, int ret) } #endif +static void bio_set_data(BIO *bio, void *data) +{ +#ifdef USE_OPENSSL_1_1_API + BIO_set_data(bio, data); +#else + bio->ptr = data; +#endif +} + +static void *bio_get_data(BIO *bio) +{ +#ifdef USE_OPENSSL_1_1_API + return BIO_get_data(bio); +#else + return bio->ptr; +#endif +} + /* Returns the amount read. */ static int bio_bucket_read(BIO *bio, char *in, int inlen) { - serf_ssl_context_t *ctx = bio->ptr; + serf_ssl_context_t *ctx = bio_get_data(bio); const char *data; apr_status_t status; apr_size_t len; @@ -291,7 +302,7 @@ static int bio_bucket_read(BIO *bio, char *in, int inlen) /* Returns the amount written. */ static int bio_bucket_write(BIO *bio, const char *in, int inl) { - serf_ssl_context_t *ctx = bio->ptr; + serf_ssl_context_t *ctx = bio_get_data(bio); serf_bucket_t *tmp; serf__log(SSL_VERBOSE, __FILE__, "bio_bucket_write called for %d bytes\n", @@ -319,19 +330,16 @@ static int bio_bucket_write(BIO *bio, const char *in, int inl) /* Returns the amount read. */ static int bio_file_read(BIO *bio, char *in, int inlen) { - apr_file_t *file = bio->ptr; + apr_file_t *file = bio_get_data(bio); apr_status_t status; apr_size_t len; - BIO_clear_retry_flags(bio); - len = inlen; status = apr_file_read(file, in, &len); if (!SERF_BUCKET_READ_ERROR(status)) { /* Oh suck. */ if (APR_STATUS_IS_EOF(status)) { - BIO_set_retry_read(bio); return -1; } else { return len; @@ -344,7 +352,7 @@ static int bio_file_read(BIO *bio, char *in, int inlen) /* Returns the amount written. */ static int bio_file_write(BIO *bio, const char *in, int inl) { - apr_file_t *file = bio->ptr; + apr_file_t *file = bio_get_data(bio); apr_size_t nbytes; BIO_clear_retry_flags(bio); @@ -357,15 +365,32 @@ static int bio_file_write(BIO *bio, const char *in, int inl) static int bio_file_gets(BIO *bio, char *in, int inlen) { - return bio_file_read(bio, in, inlen); + apr_file_t *file = bio_get_data(bio); + apr_status_t status; + + status = apr_file_gets(in, inlen, file); + + if (! status) { + return (int)strlen(in); + } else if (APR_STATUS_IS_EOF(status)) { + return 0; + } else { + return -1; /* Signal generic error */ + } } static int bio_bucket_create(BIO *bio) { +#ifdef USE_OPENSSL_1_1_API + BIO_set_shutdown(bio, 1); + BIO_set_init(bio, 1); + BIO_set_data(bio, NULL); +#else bio->shutdown = 1; bio->init = 1; bio->num = -1; bio->ptr = NULL; +#endif return 1; } @@ -399,6 +424,7 @@ static long bio_bucket_ctrl(BIO *bio, int cmd, long num, void *ptr) return ret; } +#ifndef USE_OPENSSL_1_1_API static BIO_METHOD bio_bucket_method = { BIO_TYPE_MEM, "Serf SSL encryption and decryption buckets", @@ -428,6 +454,55 @@ static BIO_METHOD bio_file_method = { NULL /* sslc does not have the callback_ctrl field */ #endif }; +#endif + +static BIO_METHOD *bio_meth_bucket_new(void) +{ + BIO_METHOD *biom = NULL; + +#ifdef USE_OPENSSL_1_1_API + biom = BIO_meth_new(BIO_TYPE_MEM, + "Serf SSL encryption and decryption buckets"); + if (biom) { + BIO_meth_set_write(biom, bio_bucket_write); + BIO_meth_set_read(biom, bio_bucket_read); + BIO_meth_set_ctrl(biom, bio_bucket_ctrl); + BIO_meth_set_create(biom, bio_bucket_create); + BIO_meth_set_destroy(biom, bio_bucket_destroy); + } +#else + biom = &bio_bucket_method; +#endif + + return biom; +} + +static BIO_METHOD *bio_meth_file_new(void) +{ + BIO_METHOD *biom = NULL; + +#ifdef USE_OPENSSL_1_1_API + biom = BIO_meth_new(BIO_TYPE_FILE, + "Wrapper around APR file structures"); + BIO_meth_set_write(biom, bio_file_write); + BIO_meth_set_read(biom, bio_file_read); + BIO_meth_set_gets(biom, bio_file_gets); + BIO_meth_set_ctrl(biom, bio_bucket_ctrl); + BIO_meth_set_create(biom, bio_bucket_create); + BIO_meth_set_destroy(biom, bio_bucket_destroy); +#else + biom = &bio_file_method; +#endif + + return biom; +} + +static void bio_meth_free(BIO_METHOD *biom) +{ +#ifdef USE_OPENSSL_1_1_API + BIO_meth_free(biom); +#endif +} typedef enum san_copy_t { EscapeNulAndCopy = 0, @@ -977,7 +1052,7 @@ static apr_status_t ssl_encrypt(void *baton, apr_size_t bufsize, return status; } -#if APR_HAS_THREADS +#if APR_HAS_THREADS && !defined(USE_OPENSSL_1_1_API) static apr_pool_t *ssl_pool; static apr_thread_mutex_t **ssl_locks; @@ -1064,7 +1139,7 @@ static void init_ssl_libraries(void) val = apr_atomic_cas32(&have_init_ssl, INIT_BUSY, INIT_UNINITIALIZED); if (!val) { -#if APR_HAS_THREADS +#if APR_HAS_THREADS && !defined(USE_OPENSSL_1_1_API) int i, numlocks; #endif @@ -1081,13 +1156,17 @@ static void init_ssl_libraries(void) } #endif +#ifdef USE_OPENSSL_1_1_API + OPENSSL_malloc_init(); +#else CRYPTO_malloc_init(); +#endif ERR_load_crypto_strings(); SSL_load_error_strings(); SSL_library_init(); OpenSSL_add_all_algorithms(); -#if APR_HAS_THREADS +#if APR_HAS_THREADS && !defined(USE_OPENSSL_1_1_API) numlocks = CRYPTO_num_locks(); apr_pool_create(&ssl_pool, NULL); ssl_locks = apr_palloc(ssl_pool, sizeof(apr_thread_mutex_t*)*numlocks); @@ -1140,6 +1219,7 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) const char *cert_path; apr_file_t *cert_file; BIO *bio; + BIO_METHOD *biom; PKCS12 *p12; int i; int retrying_success = 0; @@ -1165,8 +1245,9 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) continue; } - bio = BIO_new(&bio_file_method); - bio->ptr = cert_file; + biom = bio_meth_file_new(); + bio = BIO_new(biom); + bio_set_data(bio, cert_file); ctx->cert_path = cert_path; p12 = d2i_PKCS12_bio(bio, NULL); @@ -1176,6 +1257,7 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) if (i == 1) { PKCS12_free(p12); + bio_meth_free(biom); ctx->cached_cert = *cert; ctx->cached_cert_pw = *pkey; if (!retrying_success && ctx->cert_cache_pool) { @@ -1211,6 +1293,7 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) i = PKCS12_parse(p12, password, pkey, cert, NULL); if (i == 1) { PKCS12_free(p12); + bio_meth_free(biom); ctx->cached_cert = *cert; ctx->cached_cert_pw = *pkey; if (!retrying_success && ctx->cert_cache_pool) { @@ -1238,6 +1321,7 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) } } PKCS12_free(p12); + bio_meth_free(biom); return 0; } else { @@ -1245,6 +1329,7 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) ERR_GET_FUNC(err), ERR_GET_REASON(err)); PKCS12_free(p12); + bio_meth_free(biom); } } } @@ -1339,8 +1424,9 @@ static serf_ssl_context_t *ssl_init_context(serf_bucket_alloc_t *allocator) disable_compression(ssl_ctx); ssl_ctx->ssl = SSL_new(ssl_ctx->ctx); - ssl_ctx->bio = BIO_new(&bio_bucket_method); - ssl_ctx->bio->ptr = ssl_ctx; + ssl_ctx->biom = bio_meth_bucket_new(); + ssl_ctx->bio = BIO_new(ssl_ctx->biom); + bio_set_data(ssl_ctx->bio, ssl_ctx); SSL_set_bio(ssl_ctx->ssl, ssl_ctx->bio, ssl_ctx->bio); @@ -1383,6 +1469,7 @@ static apr_status_t ssl_free_context( /* SSL_free implicitly frees the underlying BIO. */ SSL_free(ssl_ctx->ssl); + bio_meth_free(ssl_ctx->biom); SSL_CTX_free(ssl_ctx->ctx); serf_bucket_mem_free(ssl_ctx->allocator, ssl_ctx); |
