diff options
| author | 2013-10-09 16:30:37 +0200 | |
|---|---|---|
| committer | 2013-10-09 16:30:37 +0200 | |
| commit | e9995aee384bdbac6c6afc0f4548a080eb4241bc (patch) | |
| tree | 1b0adc7cdb89725b37a6dbd199ae0475c1bad14c | |
| parent | e0fe1f58c50ed69dafc00e16250a0c7d31d15461 (diff) | |
| download | libplist-e9995aee384bdbac6c6afc0f4548a080eb4241bc.tar.gz libplist-e9995aee384bdbac6c6afc0f4548a080eb4241bc.tar.bz2 | |
base64: use strtok_r instead of strtok to make sure we're thread safe
| -rw-r--r-- | src/base64.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/base64.c b/src/base64.c index e558d9e..96d49f3 100644 --- a/src/base64.c +++ b/src/base64.c | |||
| @@ -111,13 +111,14 @@ unsigned char *base64decode(const char *buf, size_t *size) | |||
| 111 | 111 | ||
| 112 | unsigned char *line; | 112 | unsigned char *line; |
| 113 | int p = 0; | 113 | int p = 0; |
| 114 | char* saveptr = NULL; | ||
| 114 | 115 | ||
| 115 | line = (unsigned char*)strtok((char*)buf, "\r\n\t "); | 116 | line = (unsigned char*)strtok_r((char*)buf, "\r\n\t ", &saveptr); |
| 116 | while (line) { | 117 | while (line) { |
| 117 | p+=base64decode_block(outbuf+p, (const char*)line, strlen((char*)line)); | 118 | p+=base64decode_block(outbuf+p, (const char*)line, strlen((char*)line)); |
| 118 | 119 | ||
| 119 | // get next line of base64 encoded block | 120 | // get next line of base64 encoded block |
| 120 | line = (unsigned char*)strtok(NULL, "\r\n\t "); | 121 | line = (unsigned char*)strtok_r(NULL, "\r\n\t ", &saveptr); |
| 121 | } | 122 | } |
| 122 | outbuf[p] = 0; | 123 | outbuf[p] = 0; |
| 123 | *size = p; | 124 | *size = p; |
