diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-15 16:57:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-15 16:57:49 +0000 |
commit | a9410a4dc7d3238efda691a0c8c6c724010237f2 (patch) | |
tree | 474ea94288d2d6820ca6d9e548f65221e5042d22 /src/fs/gnunet-helper-fs-publish.c | |
parent | 9e3c0c39c0757598bb988b3abf488c9d0686d2a1 (diff) | |
download | gnunet-a9410a4dc7d3238efda691a0c8c6c724010237f2.tar.gz gnunet-a9410a4dc7d3238efda691a0c8c6c724010237f2.zip |
auto-correct missing 0-terminators in C_STRINGS/UTF-8 strings
Diffstat (limited to 'src/fs/gnunet-helper-fs-publish.c')
-rw-r--r-- | src/fs/gnunet-helper-fs-publish.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 2aa9df0e4..36af59cc8 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -75,7 +75,7 @@ struct ScanTreeNode | |||
75 | uint64_t file_size; | 75 | uint64_t file_size; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * GNUNET_YES if this is a directory | 78 | * #GNUNET_YES if this is a directory |
79 | */ | 79 | */ |
80 | int is_directory; | 80 | int is_directory; |
81 | 81 | ||
@@ -107,7 +107,7 @@ static int output_stream; | |||
107 | * @param data_mime_type mime-type of data (not of the original file); | 107 | * @param data_mime_type mime-type of data (not of the original file); |
108 | * can be NULL (if mime-type is not known) | 108 | * can be NULL (if mime-type is not known) |
109 | * @param data actual meta-data found | 109 | * @param data actual meta-data found |
110 | * @param data_len number of bytes in data | 110 | * @param data_len number of bytes in @a data |
111 | * @return always 0 to continue extracting | 111 | * @return always 0 to continue extracting |
112 | */ | 112 | */ |
113 | static int | 113 | static int |
@@ -117,14 +117,27 @@ add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, | |||
117 | { | 117 | { |
118 | struct GNUNET_CONTAINER_MetaData *md = cls; | 118 | struct GNUNET_CONTAINER_MetaData *md = cls; |
119 | 119 | ||
120 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | 120 | if ( ((EXTRACTOR_METAFORMAT_UTF8 == format) || |
121 | data_mime_type, data, data_len); | 121 | (EXTRACTOR_METAFORMAT_C_STRING == format)) && |
122 | ('\0' != data[data_size - 1]) ) | ||
123 | { | ||
124 | char zdata[data_len + 1]; | ||
125 | memcpy (zdata, data, data_len); | ||
126 | zdata[data_size] = '\0'; | ||
127 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | ||
128 | data_mime_type, zdata, data_len + 1); | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | ||
133 | data_mime_type, data, data_len); | ||
134 | } | ||
122 | return 0; | 135 | return 0; |
123 | } | 136 | } |
124 | 137 | ||
125 | 138 | ||
126 | /** | 139 | /** |
127 | * Free memory of the 'tree' structure | 140 | * Free memory of the @a tree structure |
128 | * | 141 | * |
129 | * @param tree tree to free | 142 | * @param tree tree to free |
130 | */ | 143 | */ |