if (ptr != NULL)
afs_osi_Free(ptr, 0);
}
+
+char*
+_afscrypto_strdup(const char *str) {
+ char *ptr;
+
+ ptr = malloc(strlen(str));
+ if (ptr == NULL)
+ return ptr;
+ memcpy(ptr, str, strlen(str));
+
+ return ptr;
+}
+
+/* This is a horrible, horrible bodge, but the crypto code uses realloc,
+ * so we need to handle it too.
+ *
+ * There are two different call sites for realloc. Firstly, it's used
+ * in the decrypt case to shrink the size of the allotted buffer. In
+ * this case, we can just ignore the realloc and return the original
+ * pointer.
+ *
+ * Secondly, it's used when computing derived keys. In this case, the
+ * first call will be with a NULL input, and the size of a single
+ * derived key. So, we just give back space for 20 keys, and pray.
+ */
+
+void *
+_afscrypto_realloc(void *ptr, size_t len) {
+ if (ptr == NULL)
+ return calloc(20, len);
+ return ptr;
+}