- if ((strncmp(target, "msdfs:", strlen("msdfs:")) == 0) &&
- (strchr_m(target, '@') != NULL)) {
- if (!expand_msdfs_target(handle->conn, target)) {
- errno = ENOENT;
- return -1;
+ /*
+ * We are always returning the values returned
+ * returned by the NEXT call, but we might mess
+ * with the reflist[i].alternate_path values,
+ * so use local pointers to minimise indirections.
+ */
+ count = *preferral_count;
+ reflist = *ppreflist;
+
+ for (i = 0; i < count; i++) {
+ if (strchr_m(reflist[i].alternate_path, '@') != NULL) {
+ char *new_altpath = expand_msdfs_target(frame,
+ handle->conn,
+ reflist[i].alternate_path);
+ if (new_altpath == NULL) {
+ TALLOC_FREE(*ppreflist);
+ *preferral_count = 0;
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
+ reflist[i].alternate_path = talloc_move(reflist,
+ &new_altpath);