summaryrefslogtreecommitdiff
path: root/src/util.c
Commit message (Collapse)AuthorAgeFilesLines
* stringmatchlen() should not expect null terminated strings.antirez2020-05-061-2/+2
|
* Remove unreachable branch.Brad Dunbar2020-05-051-2/+0
|
* getRandomBytes(): use HMAC-SHA256.antirez2020-04-231-10/+30
| | | | | | | | | | Now that we have an interface to use this API directly, via ACL GENPASS, we are no longer sure what people could do with it. So why don't make it a strong primitive exported by Redis in order to create unique IDs and so forth? The implementation was tested against the test vectors that can be found in RFC4231.
* Merge pull request #6546 from guybe7/fix_neg_zeroSalvatore Sanfilippo2020-04-021-0/+4
|\ | | | | Make sure Redis does not reply with negative zero
| * Make sure Redis does not reply with negative zeroGuy Benoish2019-11-051-0/+4
| |
* | ld2string should fail if string contains \0 in the middleGuy Benoish2020-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug affected RM_StringToLongDouble and HINCRBYFLOAT. I added tests for both cases. Main changes: 1. Fixed string2ld to fail if string contains \0 in the middle 2. Use string2ld in getLongDoubleFromObject - No point of having duplicated code here The two changes above broke RM_SaveLongDouble/RM_LoadLongDouble because the long double string was saved with length+1 (An innocent mistake, but it's actually a bug - The length passed to RM_SaveLongDouble should not include the last \0).
* | Merge branch 'unstable' into rm_get_server_infoSalvatore Sanfilippo2019-11-211-24/+36
|\ \ | |/
| * Module API for loading and saving long doubleOran Agra2019-11-031-24/+36
| | | | | | | | | | | | | | | | | | | | | | looks like each platform implements long double differently (different bit count) so we can't save them as binary, and we also want to avoid creating a new RDB format version, so we save these are hex strings using "%La". This commit includes a change in the arguments of ld2string to support this. as well as tests for coverage and short reads. coded by @guybe7
* | Add RM_ServerInfoGetFieldUnsignedOran Agra2019-11-041-0/+20
| | | | | | | | | | | | rename RM_ServerInfoGetFieldNumerical RM_ServerInfoGetFieldSigned move string2ull to util.c fix leak in RM_GetServerInfo when duplicate info fields exist
* | Add module api for looking into INFO fieldsOran Agra2019-11-031-0/+21
|/ | | | | | | | | | | | | - Add RM_GetServerInfo and friends - Add auto memory for new opaque struct - Add tests for new APIs other minor fixes: - add const in various char pointers - requested_section in modulesCollectInfo was actually not sds but char* - extract new string2d out of getDoubleFromObject for code reuse Add module API for
* Increase string2ld's buffer size (and fix HINCRBYFLOAT)Guy Benoish2019-01-281-1/+1
| | | | | | | | The string representation of `long double` may take up to ~5000 chars (see PR #3745). Before this fix HINCRBYFLOAT would never overflow (since the string could not exceed 256 chars). Now it can.
* stringmatchlen() fuzz test added.antirez2018-12-111-0/+16
| | | | | Verified to be able to trigger at least #5632. Does not report other issues.
* Fix stringmatchlen() read past buffer bug.antirez2018-12-111-1/+1
| | | | See #5632.
* fix comment typo in util.cWeiliang Li2018-11-151-1/+1
| | | | fix comment typo in util.c
* needs it for the globalDavid Carlier2018-10-261-0/+1
|
* Fix non Linux build.David Carlier2018-10-261-0/+18
| | | | | timezone global is a linux-ism whereas it is a function under BSD. Here a helper to get the timezone value in a more portable manner.
* string2ll(): better commenting.antirez2018-07-241-0/+6
|
* removing redundant checkdsomeshwar2018-07-211-3/+0
|
* Fix typoJack Drogon2018-07-031-1/+1
|
* Modules API: RM_GetRandomBytes() / GetRandomHexChars().antirez2018-04-051-59/+43
|
* Prevent off-by-one read in stringmatchlen() (fixes #4527)nashe2017-12-121-1/+1
|
* Modules: first preview 31 March 2016.antirez2016-05-101-1/+1
|
* Fix HINCRBYFLOAT to work with long doubles.antirez2015-11-041-3/+3
| | | | | | | | | | | | | | | | | During the refactoring needed for lazy free, specifically the conversion of t_hash from struct robj to plain SDS strings, HINCRBFLOAT was accidentally moved away from long doubles to doubles for internal processing of increments and formatting. The diminished precision created more obvious artifacts in the way small numbers are formatted once we convert from decimal number in radix 10 to double and back to its string in radix 10. By using more precision, we now have less surprising results at least with small numbers like "1.23", exactly like in the previous versions of Redis. See issue #2846.
* Lazyfree: Hash converted to use plain SDS WIP 5.antirez2015-10-011-3/+3
|
* Lazyfree: Hash converted to use plain SDS WIP 4.antirez2015-10-011-4/+8
|
* Lazyfree: Hash converted to use plain SDS WIP 2.antirez2015-10-011-1/+51
|
* Lazyfree: Hash converted to use plain SDS WIP 1.antirez2015-10-011-1/+34
|
* Utils: Include stdint.h and fix signess in sdigits10().antirez2015-02-271-1/+1
|
* Utils: added function to get radix 10 string length of signed integer.antirez2015-02-271-0/+12
|
* Better memtoll() error checking.antirez2015-02-121-5/+18
| | | | Related to PR #2357.
* The seed must be static in getRandomHexChars().antirez2015-01-221-1/+1
|
* counter must be static in getRandomHexChars().antirez2015-01-221-2/+4
|
* getRandomHexChars(): use /dev/urandom just to seed.antirez2015-01-211-8/+38
| | | | | | | | | On Darwin /dev/urandom depletes terribly fast. This is not an issue normally, but with Redis Cluster we generate a lot of unique IDs, for example during nodes handshakes. Our IDs need just to be unique without other strong crypto requirements, so this commit turns the function into something that gets a 20 bytes seed from /dev/urandom, and produces the rest of the output just using SHA1 in counter mode.
* Add simple ll2string() testsMatt Stancliff2014-12-231-0/+42
|
* Allow all code tests to run using Redis argsMatt Stancliff2014-12-231-4/+8
| | | | | | | | | | | | | | | | | | | | | Previously, many files had individual main() functions for testing, but each required being compiled with their own testing flags. That gets difficult when you have 8 different flags you need to set just to run all tests (plus, some test files required other files to be compiled aaginst them, and it seems some didn't build at all without including the rest of Redis). Now all individual test main() funcions are renamed to a test function for the file itself and one global REDIS_TEST define enables testing across the entire codebase. Tests can now be run with: - `./redis-server test <test>` e.g. ./redis-server test ziplist If REDIS_TEST is not defined, then no tests get included and no tests are included in the final redis-server binary.
* Clean up text throughout projectMatt Stancliff2014-09-291-1/+1
| | | | | | | | | | - Remove trailing newlines from redis.conf - Fix comment misspelling - Clarifies zipEncodeLength usage and a C API mention (#1243, #1242) - Fix cluster typos (inspired by @papanikge #1507) - Fix rewite -> rewrite in a few places (inspired by #682) Closes #1243, #1242, #1507
* Fix undefined behavior in ll2string().antirez2014-08-151-1/+5
| | | | | The bug was found by @CAFxX, thanks! See issue #1940.
* Fix util.c compilation by including stdint.h.antirez2014-07-231-0/+1
|
* Faster ll2string() implementation.antirez2014-07-231-21/+80
| | | | | | | | | | | | | | | | Based on ideas documented in this blog post: https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920 The original code was modified to handle signed integers, reformetted to fit inside the Redis code base, and was stress-tested with a program in order to validate the implementation against snprintf(). Redis was measured to be measurably faster from the point of view of clients in real-world operations because of this change, since sometimes number to string conversion is used extensively (for example every time a GET results into an integer encoded object to be returned to the user).
* fix null pointer access with no file pointerGlauber Costa2014-04-231-1/+1
| | | | | | I happen to be working on a system that lacks urandom. While the code does try to handle this case and artificially create some bytes if the file pointer is empty, it does try to close it unconditionally, leading to a segfault.
* Ignore sdsrange return value.antirez2013-07-241-2/+2
|
* pathIsBaseName() added to utils.cantirez2013-07-021-0/+8
| | | | | The function is used to test that the specified string looks like just as the basename of a path, without any absolute or relative path.
* getAbsolutePath() moved into utils.cantirez2013-07-021-0/+52
|
* BSD license added to every C source and header file.antirez2012-11-081-0/+29
|
* Use correct variable name for value to convert.Michael Parker2012-07-311-1/+2
| | | | | | | | | Note by @antirez: this code was never compiled because utils.c lacked the float.h include, so we never noticed this variable was mispelled in the past. This should provide a noticeable speed boost when saving certain types of databases with many sorted sets inside.
* Merge conflicts resolved.antirez2012-03-091-3/+3
|\
| * string2* functions take a const pointerPieter Noordhuis2012-01-021-3/+3
| |
* | clusterGetRandomName() generalized into getRandomHexChars() so that we can ↵antirez2012-03-081-0/+48
|/ | | | use it for the run_id field as well.
* fmacros in utils.c to avoid warning about strcasecmp()antirez2011-05-161-0/+2
|
* Extra tests for string2llPieter Noordhuis2011-05-051-0/+8
|