]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix base32hex code
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 22 Sep 2020 06:13:13 +0000 (08:13 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 23 Sep 2020 07:41:38 +0000 (09:41 +0200)
- Const-ified input parameter.
- Use non-reserved macro for the include guard.
- Use unsigned int buffer to avoid “left shift of 1236923897 by 8 places
  cannot be represented in type int” reported by Clang’s
  UndefinedBehaviorSanitizer.

src/third_party/base32hex.c
src/third_party/base32hex.h

index 354c04371074a03f7838402b38ae24d52d32803f..aebfab5d5f08ef4825cf2d3c3f636b46f9f90812 100644 (file)
@@ -22,7 +22,7 @@
  * See RFC-4648. This implementation produces lowercase hex characters.
  * Returns length of encoded string.
  */
-unsigned int base32hex(char *out, uint8_t *in, unsigned int len) {
+unsigned int base32hex(char *out, const uint8_t *in, unsigned int len) {
 int buf = 0, bits = 0;
 char *x = out;
 
index 0ea92abd4dccb83eb1df053170ffd5f6b9cddb52..838671973e6a17c98dd2d23a8bb26e855bb6d545 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _BASE32_HEX_H
-#define _BASE32_HEX_H
+#ifndef BASE32_HEX_H
+#define BASE32_HEX_H
 
 #include <stdint.h>
 
-extern unsigned int base32hex(char *out, uint8_t *in, unsigned int len);
+extern unsigned int base32hex(char *out, const uint8_t *in, unsigned int len);
 
 #endif