aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-09-08 19:46:14 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-09-08 19:57:34 +0200
commit81017b0fc2a45d83e045b234b9c66f26323fdab2 (patch)
tree67e60d4b1ff8419f3e180ab7eeab225a7bd03d02 /src
parent4a5b72a535922c14588dcb8c36c968a6147c00a0 (diff)
downloadlibssh-81017b0fc2a45d83e045b234b9c66f26323fdab2.tar.gz
libssh-81017b0fc2a45d83e045b234b9c66f26323fdab2.tar.xz
libssh-81017b0fc2a45d83e045b234b9c66f26323fdab2.zip
string: Make sure we always have the right byte order.
Diffstat (limited to 'src')
-rw-r--r--src/string.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/string.c b/src/string.c
index 37fe42e6..c2ee2978 100644
--- a/src/string.c
+++ b/src/string.c
@@ -75,7 +75,7 @@ struct ssh_string_struct *ssh_string_new(size_t size) {
*/
int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len) {
if ((s == NULL) || (data == NULL) ||
- (len == 0) || (len > s->size)) {
+ (len == 0) || (len > ssh_string_len(s))) {
return -1;
}
@@ -165,7 +165,7 @@ char *ssh_string_to_char(struct ssh_string_struct *s) {
char *new;
if (s == NULL || s->data == NULL)
return NULL;
- len = ntohl(s->size) + 1;
+ len = ssh_string_len(s) + 1;
new = malloc(len);
if (new == NULL) {
@@ -200,12 +200,12 @@ struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s) {
return NULL;
}
- new = ssh_string_new(s->size);
+ new = ssh_string_new(ssh_string_len(s));
if (new == NULL) {
return NULL;
}
- new->size = s->size;
- memcpy(new->data, s->data, ntohl(s->size));
+
+ memcpy(new->data, s->data, ssh_string_len(s));
return new;
}