1
0
mirror of https://github.com/mariadb-corporation/libmarias3.git synced 2025-08-09 19:22:43 +03:00

51 Commits

Author SHA1 Message Date
Andrew Hutchings
cfa1f7fcbb Fix version history (#135) 2024-09-27 10:39:37 +01:00
Andrew Hutchings
e97fe760b4 Fix ms3_copy for non-alphanumeric characters
The S3 API specification states that x-amz-copy-source should be
urlencoded. libmarias3 wasn't doing this but Amazon's S3 implementation
appeared to be forgiving enough that it didn't matter. When using
compatible APIs such as MinIO this requirement became stricter.

The code now urlencodes the source path for ms3_copy / ms3_move.

In addition this patch adds support for MinIO in the test suite by
adding environment variables for port and disabling https.
2020-10-20 13:17:09 +01:00
Andrew Hutchings
d766a449c5 Add new XML parser and fix bugs
LibXML has been removed in favour of a modified version of xml.c
(modified to work with AWS responses and our code base usage).

Also fixes:

* AC_MSG_ERROR usage (fixes #83)
* Some places where we weren't using ms3_c alloc functions
* ms3_get doing an ms3_list with an empty key (fixes #82)
2020-04-20 19:49:52 +01:00
Andrew Hutchings
74baa5b823 Add credits for code 2020-01-29 21:04:06 +00:00
Andrew Hutchings
a3523c694a Revert "Remove domain bucket access method"
This reverts commit 7a02ffa83c.
2019-10-31 16:19:01 +00:00
Andrew Hutchings
7a02ffa83c Remove domain bucket access method
"Buckets created in Regions launched after March 20, 2019 are not
reachable via the https://bucket.s3.amazonaws.com naming scheme."

This patch enhances the one Markus wrote to just completely remove the
domain based access method.
2019-10-30 11:32:42 +00:00
Andrew Hutchings
b9ffda81d9 Fix libcurl/openssl thread safety issues
If libcurl was built with OpenSSL < 1.1.0 then there is a potential
thread safety issue which can cause libmarias3 to crash.

This fix detects which version of OpenSSL (if any) that libcurl was
built with and adds thread locking callbacks to OpenSSL if found unsafe.

Fixes mariadb-corporation/libmarias3#70
2019-09-30 16:19:14 +01:00
Andrew Hutchings
9d3e5f7c64 Add GCloud S3 support
Google Cloud has some weird behaviours we need to support:

* Auth keys are longer than the fixed 20 characters of AWS
* Header responses are lower case
* DELETE returns a 404 on file not found

Fixes mariadb-corporation/libmarias3#71
2019-08-20 17:30:38 +01:00
Andrew Hutchings
cfde4a9c5d Improve linked list memory handling
Now does 2 mallocs per 1024 list entries. Makes ms3_list_free() a NULL
operation (all handled internally now).
2019-06-28 10:34:31 +01:00
Andrew Hutchings
9121dad663 Fix S3 compatible compatibility
* Fix path based access
* Improved autodetection of type of method to use
2019-06-26 15:36:46 +01:00
Andrew Hutchings
1e824da439 Fix version history doc 2019-06-24 10:33:04 +01:00
Andrew Hutchings
5b77fc6d81 Cleanup m4 usage
Remove a lot of unneeded things
2019-06-03 12:02:23 +01:00
Andrew Hutchings
e888c301d9 Add UTF-8 test
Also some minor cleanups
2019-06-03 11:28:56 +01:00
Andrew Hutchings
fd981671fd Fix double-free after error 2019-06-01 11:54:17 +01:00
Andrew Hutchings
dab8185b94 Fix verison history 2019-05-31 15:25:05 +01:00
Andrew Hutchings
e850cd25b9 Fix warnings and add force protocol option
Add the warning -Wdeclaration-after-statement and fix everything it
finds.

Add MS3_OPT_FORCE_PROTOCOL_VERSION to ms3_set_option() with a test to
force protocol version when the autodetection does the wrong thing.
2019-05-31 15:22:51 +01:00
Andrew Hutchings
5efa623226 Fix compiling issue in C90 mode 2019-05-31 13:51:33 +01:00
Andrew Hutchings
fe7839aff3 Performance improvements
Several performance improvements
2019-05-24 18:18:59 +01:00
Andrew Hutchings
4d69191da4 Remove mhash dependency
Instead use code based on wpa_supplicant.
2019-05-21 12:41:15 +01:00
Andrew Hutchings
638e28ca84 Fix libm linkage
We now need to link to libm
2019-05-20 19:41:13 +01:00
Andrew Hutchings
604a110f6d Fix two potential crashes in err msg handling
* The error response may not be the XML we expect which would cause a
NULL node to be dereferenced
* Setting the server error message with a NULL message would cause a
double-free
2019-05-16 15:02:30 +01:00
Andrew Hutchings
d6442ac9a4 Fix several memory issues
* Fix a few potential pointer arithmatic issues
* Fix race condition on time generation
* Added TSAN to ci-scripts
* Fix minor issues found in cppcheck
* Stop buffer overrun if the buffer chunk size is set smaller than packet
* Fix ms3_get() returning random data if a CURL request completely fails

Fixes mariadb-corporation/libmarias3#55
2019-05-15 07:39:14 +01:00
Andrew Hutchings
fd3662cdab Use a no-copy method of sending data
Use a pointer which is pushed straight to network instead of the
callback which does memcpy to a buffer. In tests this provides up to 20%
performance improvement.
2019-05-13 13:08:43 +01:00
Andrew Hutchings
598c364742 Cleanups for removing C99 support and 3.0 release
* Remove bool from public interface
* Fix CLang compiling
* Remove deprecated functions
* Bump version

Fixes mariadb-corporation/libmarias3#51
2019-05-13 10:18:44 +01:00
Andrew Hutchings
de006e40db Allow gnu89 compiling
Allow compiling on older compilers without enforcing C99.
2019-05-10 09:47:41 +01:00
Andrew Hutchings
2f818d5904 Add ms3_list_dir()
This function acts like ms3_list() but only looks in the prefix up to
the first slash and includes directory names.

Also remove the 1MB lower limit on chunk size
2019-05-07 12:01:13 +01:00
Andrew Hutchings
a856148b69 Fix error in data for ms3_get
If an error occurs in ms3_get the error response can be returned as
data. Which if not freed by the application can lead to a leak.

We now free this data after the error message has been extracted.

Also bump version.
2019-05-07 08:53:26 +01:00
Andrew Hutchings
5cc2e27f92 Fix logic error in ms3_move
ms3_move would execute copy and then delete on error rather than delete
on no error. Test was similarly broken.
2019-05-06 07:22:09 +01:00
Andrew Hutchings
e8a54506bc Add ms3_copy() and ms3_move() functions
These implement internal S3 copy functionality
2019-04-23 07:36:28 +01:00
Andrew Hutchings
a8366f602a Add library deinit and improve init_malloc
Add deinit to cleanup library and make return code for init_malloc
consistent.
2019-04-22 07:47:22 +01:00
Andrew Hutchings
11f5226197 Add init function with custom malloc
You can now specify a custom allocator

Fixes mariadb-corporation/libmarias3#39
2019-04-21 10:29:29 +01:00
Andrew Hutchings
a4b269d14b Add ms3_init() to replace ms3_thread_init()
Helps with confusing name.

Fixes mariadb-corporation/libmarias3#40
2019-04-21 09:31:17 +01:00
Andrew Hutchings
808ac78b20 Improve third-party S3 API support
* Autoswitch to bucket path instead of bucket domain access method (for IP urls)
* Fixed issue with SSL disabled verification
* Fixed minor leak when base_domain is set
* Add ``S3NOVERIFY`` env var to tests which will disable SSL verification when set to ``1``
2019-04-02 08:15:29 +01:00
Andrew Hutchings
55534feb6b Remove iso646.h support
As requested by users
2019-04-01 09:10:54 +01:00
Andrew Hutchings
c5d3f728ee Add V1 bucket list API support
* Will use V1 by default for non-Amazon S3 servers
* V1 or V2 can be forced using ms3_set_option()
* Updated tests to test for both
* Set version and ABI version correctly
2019-03-29 09:37:16 +00:00
Andrew Hutchings
cf300d35ca Add ms3_set_option() and several options
* Add ms3_set_option() API call
* Add options for http:// instead of https://, disabling SSL
verification and buffer chunk size.
* Deprecated ms3_buffer_chunk_size() (use ms3_set_option() instead)
* Added server/curl error messages to debugging output
2019-03-29 08:35:58 +00:00
Andrew Hutchings
1f08de4351 Add ms3_server_error() and remove ms3_init()
* ms3_server_error() gets the last server error or Curl error
* Remove the deprecated ms3_init(), it could not work with
ms3_server_error() and no one uses it
* Test cleanups
* Version bump for semver
2019-03-28 20:54:39 +00:00
Andrew Hutchings
467d59502a Cleanup linking
Fixes mariadb-corporation/libmarias3#18
2019-03-28 17:54:35 +00:00
Andrew Hutchings
7b3b3d6701 Add ms3_buffer_chunk_size()
Allows you to increase the buffer chunk size for the receive buffer to
reduce reallocs.

Fixes mariadb-corporation/libmarias3#26
2019-03-28 17:37:04 +00:00
Andrew Hutchings
b0ad2d9274 Add function ms3_free()
To free data allocated by ms3_get.

Fixes mariadb-corporation/libmarias3#17
2019-03-28 17:17:33 +00:00
Andrew Hutchings
d0bffbb031 Treat empty base_domain as NULL
Fixes mariadb-corporation/libmarias3#21
2019-03-28 17:01:58 +00:00
Andrew Hutchings
0853f84202 Improve GET performance for large files
* ms3_get() was calling realloc every 16KB which caused it to be CPU
heavy on large files. We now use 1MB buffers instead.
* Make longlist test use a different prefix so that it doesn't generate
a random bad count if other tests are running
2019-03-28 14:24:05 +00:00
Andrew Hutchings
9fab555868 Fix PUT for files >= 64KB
We were adding buffers instead of multiplying which meant a return of
65537 bytes when the buffer was only 1 * 65536 bytes.
2019-03-28 11:30:20 +00:00
Andrew Hutchings
78d7f7387f Fix double free on error with curl 2019-03-27 14:50:34 +00:00
Andrew Hutchings
a99add660a Add connection reuse functionality
CURL will automatically reuse connections if the CURL object is reused.
This commit adds functionality so that a thread can have a CURL object
that can be reused without dramatically altering the API.

It add two new functions:

* ms3_library_init() - to initialize curl for multithreaded operations
* ms3_thread_init() - to initialize a connection object for a thread

This patch also fixes tests that are affecting each other.
2019-03-27 08:23:27 +00:00
Andrew Hutchings
17704c06dd Fix memory leaks in curl usage 2019-03-26 21:33:33 +00:00
Andrew Hutchings
28cba2ca41 Fix basic test failure
* Sometimes HEAD can 404 the first time, so try a few times if needed
* Fix some libxml2 leaks
* Fixup ci-scripts
* Fixup debug
* Add USAN test
2019-03-26 20:51:25 +00:00
Andrew Hutchings
f2b554a081 Make ms3_list() use paginated calls
Before this the list response was capped at 1000 items.

This fix also makes ms3_list() thread safe.
2019-03-26 11:00:35 +00:00
Andrew Hutchings
b9e4b77be1 Add package building docs 2019-03-25 13:55:19 +00:00
Andrew Hutchings
7b6e98482e Version bump to 1.0.1 2019-03-23 06:46:42 +00:00