summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/bplist.c b/src/bplist.c
index a9724b8..1ecbd66 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -1023,9 +1023,8 @@ static void write_data(bytearray_t * bplist, uint8_t * val, uint64_t size)
1023 write_raw_data(bplist, BPLIST_DATA, val, size); 1023 write_raw_data(bplist, BPLIST_DATA, val, size);
1024} 1024}
1025 1025
1026static void write_string(bytearray_t * bplist, char *val) 1026static void write_string(bytearray_t * bplist, char *val, uint64_t size)
1027{ 1027{
1028 uint64_t size = strlen(val);
1029 write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size); 1028 write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size);
1030} 1029}
1031 1030
@@ -1188,7 +1187,6 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
1188 uint64_t *offsets = NULL; 1187 uint64_t *offsets = NULL;
1189 bplist_trailer_t trailer; 1188 bplist_trailer_t trailer;
1190 //for string 1189 //for string
1191 long len = 0;
1192 long items_read = 0; 1190 long items_read = 0;
1193 long items_written = 0; 1191 long items_written = 0;
1194 uint16_t *unicodestr = NULL; 1192 uint16_t *unicodestr = NULL;
@@ -1256,14 +1254,13 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
1256 1254
1257 case PLIST_KEY: 1255 case PLIST_KEY:
1258 case PLIST_STRING: 1256 case PLIST_STRING:
1259 len = strlen(data->strval); 1257 if ( is_ascii_string(data->strval, data->length) )
1260 if ( is_ascii_string(data->strval, len) )
1261 { 1258 {
1262 write_string(bplist_buff, data->strval); 1259 write_string(bplist_buff, data->strval, data->length);
1263 } 1260 }
1264 else 1261 else
1265 { 1262 {
1266 unicodestr = plist_utf8_to_utf16(data->strval, len, &items_read, &items_written); 1263 unicodestr = plist_utf8_to_utf16(data->strval, data->length, &items_read, &items_written);
1267 write_unicode(bplist_buff, unicodestr, items_written); 1264 write_unicode(bplist_buff, unicodestr, items_written);
1268 free(unicodestr); 1265 free(unicodestr);
1269 } 1266 }