mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
DiscoveryPhase: Fix the unlikely case the server resturns utf-8 in permissions
UTF-8 size might be bigger than the size of the QString In that case we would end up with a non-nill terminated permissions.
This commit is contained in:
parent
5dcb276376
commit
6df7551bdd
1 changed files with 4 additions and 3 deletions
|
@ -217,17 +217,18 @@ static csync_vio_file_stat_t* propertyMapToFileStat(QMap<QString,QString> map)
|
||||||
file_stat->directDownloadCookies = strdup(value.toUtf8());
|
file_stat->directDownloadCookies = strdup(value.toUtf8());
|
||||||
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_DIRECTDOWNLOADCOOKIES;
|
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_DIRECTDOWNLOADCOOKIES;
|
||||||
} else if (property == "permissions") {
|
} else if (property == "permissions") {
|
||||||
|
auto v = value.toUtf8();
|
||||||
if (value.isEmpty()) {
|
if (value.isEmpty()) {
|
||||||
// special meaning for our code: server returned permissions but are empty
|
// special meaning for our code: server returned permissions but are empty
|
||||||
// meaning only reading is allowed for this resource
|
// meaning only reading is allowed for this resource
|
||||||
file_stat->remotePerm[0] = ' ';
|
file_stat->remotePerm[0] = ' ';
|
||||||
// see _csync_detect_update()
|
// see _csync_detect_update()
|
||||||
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_PERM;
|
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_PERM;
|
||||||
} else if (value.length() < int(sizeof(file_stat->remotePerm))) {
|
} else if (v.length() < int(sizeof(file_stat->remotePerm))) {
|
||||||
strncpy(file_stat->remotePerm, value.toUtf8(), sizeof(file_stat->remotePerm));
|
strncpy(file_stat->remotePerm, v.constData(), sizeof(file_stat->remotePerm));
|
||||||
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_PERM;
|
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_PERM;
|
||||||
} else {
|
} else {
|
||||||
// old server, keep file_stat->remotePerm empty
|
qWarning() << "permissions too large" << v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue