summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2008-11-05 17:08:47 +0000
committerGreg Hudson <ghudson@mit.edu>2008-11-05 17:08:47 +0000
commitddf60ba5e894ad339c96c6f61446dfc8cb79e779 (patch)
tree7c422431eee6bfe27aa691c05f8a1741b8934397 /src/util
parent34bf3f538cc063b49fc9ac691d617522a7962e19 (diff)
downloadkrb5-ddf60ba5e894ad339c96c6f61446dfc8cb79e779.tar.gz
krb5-ddf60ba5e894ad339c96c6f61446dfc8cb79e779.tar.xz
krb5-ddf60ba5e894ad339c96c6f61446dfc8cb79e779.zip
Rename krb5int_buf_cstr to krb5int_buf_data, since k5bufs can be used
for binary data as well as C string data. The buffer will always have a null byte at krb5int_buf_len bytes regardless of whether it contains C string data. ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21003 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/support/k5buf.c2
-rw-r--r--src/util/support/libkrb5support-fixed.exports2
-rw-r--r--src/util/support/t_k5buf.c32
3 files changed, 18 insertions, 18 deletions
diff --git a/src/util/support/k5buf.c b/src/util/support/k5buf.c
index 974893d6e..0bdffb1ad 100644
--- a/src/util/support/k5buf.c
+++ b/src/util/support/k5buf.c
@@ -192,7 +192,7 @@ void krb5int_buf_truncate(struct k5buf *buf, size_t len)
}
-char *krb5int_buf_cstr(struct k5buf *buf)
+char *krb5int_buf_data(struct k5buf *buf)
{
return (buf->buftype == ERROR) ? NULL : buf->data;
}
diff --git a/src/util/support/libkrb5support-fixed.exports b/src/util/support/libkrb5support-fixed.exports
index 1b4b0a8a3..fef8fbac7 100644
--- a/src/util/support/libkrb5support-fixed.exports
+++ b/src/util/support/libkrb5support-fixed.exports
@@ -35,6 +35,6 @@ krb5int_buf_add
krb5int_buf_add_len
krb5int_buf_add_fmt
krb5int_buf_truncate
-krb5int_buf_cstr
+krb5int_buf_data
krb5int_buf_len
krb5int_free_buf
diff --git a/src/util/support/t_k5buf.c b/src/util/support/t_k5buf.c
index cfb2547f6..bb60db440 100644
--- a/src/util/support/t_k5buf.c
+++ b/src/util/support/t_k5buf.c
@@ -63,7 +63,7 @@ static void test_basic()
krb5int_buf_add(&buf, "Hello ");
krb5int_buf_add_len(&buf, "world", 5);
check_buf(&buf, "basic fixed");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || strcmp(s, "Hello world") != 0 || len != 11, "basic fixed");
@@ -71,7 +71,7 @@ static void test_basic()
krb5int_buf_add_len(&buf, "Hello", 5);
krb5int_buf_add(&buf, " world");
check_buf(&buf, "basic dynamic");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || strcmp(s, "Hello world") != 0 || len != 11, "basic dynamic");
krb5int_free_buf(&buf);
@@ -93,7 +93,7 @@ static void test_realloc()
krb5int_buf_add_len(&buf, data, 128);
fail_if(buf.space != 256, "realloc 1");
check_buf(&buf, "realloc 1");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 138 || memcmp(s, data, len) != 0, "realloc 1");
@@ -101,7 +101,7 @@ static void test_realloc()
krb5int_buf_add_len(&buf, data, 128);
fail_if(buf.space != 512, "realloc 2");
check_buf(&buf, "realloc 2");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 266 || memcmp(s, data, len) != 0, "realloc 2");
krb5int_free_buf(&buf);
@@ -112,7 +112,7 @@ static void test_realloc()
krb5int_buf_add_len(&buf, data, 256);
fail_if(buf.space != 512, "realloc 3");
check_buf(&buf, "realloc 3");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 266 || memcmp(s, data, len) != 0, "realloc 3");
krb5int_free_buf(&buf);
@@ -123,7 +123,7 @@ static void test_realloc()
krb5int_buf_add_len(&buf, data, 512);
fail_if(buf.space != 1024, "realloc 4");
check_buf(&buf, "realloc 4");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 522 || memcmp(s, data, len) != 0, "realloc 4");
krb5int_free_buf(&buf);
@@ -133,7 +133,7 @@ static void test_realloc()
krb5int_buf_add_len(&buf, data, 10);
krb5int_buf_add_len(&buf, NULL, SPACE_MAX);
check_buf(&buf, "realloc 5");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(buf.buftype != ERROR || s != NULL || len != -1, "realloc 5");
krb5int_free_buf(&buf);
@@ -143,7 +143,7 @@ static void test_realloc()
krb5int_buf_add_len(&buf, data, 100);
krb5int_buf_add_len(&buf, NULL, SPACE_MAX * 2);
check_buf(&buf, "realloc 6");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(buf.buftype != ERROR || s != NULL || len != -1, "realloc 6");
krb5int_free_buf(&buf);
@@ -160,7 +160,7 @@ static void test_overflow()
krb5int_buf_add(&buf, "12345");
krb5int_buf_add(&buf, "12345");
check_buf(&buf, "overflow 1");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(buf.buftype != ERROR || s != NULL || len != -1, "overflow 1");
@@ -169,7 +169,7 @@ static void test_overflow()
krb5int_buf_add(&buf, "12345");
krb5int_buf_add_len(&buf, NULL, SPACE_MAX * 2);
check_buf(&buf, "overflow 2");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(buf.buftype != ERROR || s != NULL || len != -1, "overflow 2");
}
@@ -204,7 +204,7 @@ static void test_truncate()
krb5int_buf_add(&buf, "fghij");
krb5int_buf_truncate(&buf, 7);
check_buf(&buf, "truncate");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 7 || strcmp(s, "abcdefg") != 0, "truncate");
krb5int_free_buf(&buf);
@@ -220,7 +220,7 @@ static void test_binary()
krb5int_buf_add_len(&buf, data, 3);
krb5int_buf_add_len(&buf, data, 3);
check_buf(&buf, "binary");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 6, "binary");
fail_if(s[0] != 'a' || s[1] != 0 || s[2] != 'b', "binary");
@@ -244,14 +244,14 @@ static void test_fmt()
krb5int_buf_add(&buf, "foo");
krb5int_buf_add_fmt(&buf, " %d ", 3);
check_buf(&buf, "fmt 1");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 6 || strcmp(s, "foo 3 ") != 0, "fmt 1");
/* Overflow the same buffer with formatted text. */
krb5int_buf_add_fmt(&buf, "%d%d%d%d", 1, 2, 3, 4);
check_buf(&buf, "fmt 2");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(buf.buftype != ERROR || s != NULL || len != -1, "fmt 2");
@@ -260,7 +260,7 @@ static void test_fmt()
krb5int_buf_add(&buf, "foo");
krb5int_buf_add_fmt(&buf, " %d ", 3);
check_buf(&buf, "fmt 3");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 6 || strcmp(s, "foo 3 ") != 0, "fmt 3");
@@ -268,7 +268,7 @@ static void test_fmt()
krb5int_buf_add_fmt(&buf, "%s", data);
check_buf(&buf, "fmt 4");
fail_if(buf.space != 2048, "fmt 4");
- s = krb5int_buf_cstr(&buf);
+ s = krb5int_buf_data(&buf);
len = krb5int_buf_len(&buf);
fail_if(!s || len != 1029 || strcmp(s + 6, data) != 0, "fmt 4");
krb5int_free_buf(&buf);