[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/gl
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/gl |
Date: |
Sun, 28 Nov 2004 05:50:40 +0100 |
Update of /home/cvs/gsasl/lib/gl
In directory dopio:/tmp/cvs-serv2819/gl
Modified Files:
base64.c
Log Message:
Update.
--- /home/cvs/gsasl/lib/gl/base64.c 2004/11/28 04:17:41 1.5
+++ /home/cvs/gsasl/lib/gl/base64.c 2004/11/28 04:50:38 1.6
@@ -20,6 +20,26 @@
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
*
* See also RFC 3548 <http://www.ietf.org/rfc/rfc3548.txt>.
+ *
+ * Be careful with error checking. Here is how you would typically
+ * use these functions:
+ *
+ * int ok = base64_decode_alloc (in, inlen, &out, &outlen);
+ * if (!ok)
+ * FAIL: input was not valid base64
+ * if (outlen == SIZE_MAX)
+ * FAIL: integer overflow (too large input)
+ * if (out == NULL)
+ * FAIL: memory allocation error
+ * OK: data in OUT/OUTLEN
+ *
+ * size_t outlen = base64_encode_alloc (in, inlen, &out);
+ * if (outlen == SIZE_MAX)
+ * FAIL: integer overflow
+ * if (out == NULL)
+ * FAIL: memory allocation error
+ * OK: data in OUT/LEN.
+ *
*/
#ifdef HAVE_CONFIG_H
@@ -76,11 +96,11 @@
from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e.,
the length of the encoded data, excluding the terminating zero. On
return, the OUT variable will hold a pointer to newly allocated
- memory that must be deallocated by the caller, or NULL on memory
- allocation failure. If output length would overflow, SIZE_MAX is
- returned and OUT is set to NULL. If memory allocation fail, OUT is
- set to NULL, and the return value indicate length of the requested
- memory block, i.e., BASE64_LENGTH(inlen) + 1. */
+ memory that must be deallocated by the caller. If output length
+ would overflow, SIZE_MAX is returned and OUT is set to NULL. If
+ memory allocation fail, OUT is set to NULL, and the return value
+ indicate length of the requested memory block, i.e.,
+ BASE64_LENGTH(inlen) + 1. */
size_t
base64_encode_alloc (const char *in, size_t inlen, char **out)
{
@@ -356,7 +376,8 @@
return true;
}
- needlen = 3 * inlen / 4; /* FIXME: May allocate one 1 or 2 bytes too
+ needlen = 3 * inlen / 4; /* FIXME: Rewrite to avoid overflowing.
+ FIXME: May allocate one 1 or 2 bytes too
much, depending on input. */
*out = malloc (needlen);
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/25
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/25
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/26
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/27
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/27
- CVS gsasl/lib/gl,
gsasl-commit <=
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/28
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/29
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/29
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/30
- CVS gsasl/lib/gl, gsasl-commit, 2004/11/30