* Simple heuristic, strlen by two should give enough room for NFC to
* NFD conversion.
*/
- nfd_buf_size = nfc_len * 2;
+ nfd_buf_size = nfc_len * 2 + 1;
nfd_path = talloc_array(meta, char, nfd_buf_size);
if (nfd_path == NULL) {
return false;
}
dest = nfd_path;
- dest_remaining = talloc_array_length(dest);
+ dest_remaining = talloc_array_length(dest) - 1;
nconv = smb_iconv(mds_ctx->ic_nfc_to_nfd,
&nfc_path,
if (nconv == (size_t)-1) {
return false;
}
+ *dest = '\0';
for (i = 0; i < metacount; i++) {
attribute = dalloc_get_object(reqinfo, i);
char *elastic_query_len_str = NULL;
char *hostname = NULL;
bool pretty = false;
+ const char *nfd_path = NULL;
+ char nfc_buf[PATH_MAX] = {};
+ char *nfc_path = nfc_buf;
+ size_t nfd_len, nfc_remaining;
+ size_t nconv;
req = tevent_req_create(mem_ctx, &state, struct mds_es_search_state);
if (req == NULL) {
return tevent_req_post(req, ev);
}
+ nfd_path = s->slq->path_scope;
+ nfc_remaining = sizeof(nfc_buf);
+ nfd_len = strlen(nfd_path);
+ nconv = smb_iconv(s->mds_es_ctx->mds_ctx->ic_nfd_to_nfc,
+ &nfd_path,
+ &nfd_len,
+ &nfc_path,
+ &nfc_remaining);
+ if (nconv == (size_t)-1) {
+ DBG_ERR("smb_iconv NFD to NFC failed for: %s\n",
+ s->slq->path_scope);
+ tevent_req_error(req, EIO);
+ return tevent_req_post(req, ev);
+ }
+ *nfc_path = '\0';
+ s->slq->path_scope = talloc_strdup(s->slq, nfc_buf);
+ if (tevent_req_nomem(s->slq->path_scope, req)) {
+ return tevent_req_post(req, ev);
+ }
+ DBG_DEBUG("Converted path_scope to NFC: %s\n", s->slq->path_scope);
+
elastic_query = talloc_asprintf(
state,
MDSSVC_ELASTIC_QUERY_TEMPLATE,