DiskUtils.TryGetReparseDataBuffer reads a struct from unzeroed pooled memory and ignores the number of bytes returned
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- Une demi-journée
- Accessibilité débutants
- 57/100
Piste de recherche
Start with TruePath/DiskUtils.cs at TryGetReparseDataBuffer and inspect how DeviceIoControl reports the number of bytes returned. Check how IsJunction consumes the result and how SymbolicLinkReparseBuffer represents tag-specific fields. Done when short responses cannot produce a successful read of stale data and fields are interpreted according to the reparse tag.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
DiskUtils.TryGetReparseDataBuffer reads a SymbolicLinkReparseBuffer out of a buffer rented from ArrayPool<byte>.Shared:
byte[] buffer = ArrayPool<byte>.Shared.Rent(MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
// ... DeviceIoControl(..., out _, ...) // bytes returned are discarded
Span<byte> bufferSpan = new(buffer);
success = MemoryMarshal.TryRead(bufferSpan, out SymbolicLinkReparseBuffer reparseDataBuffer);
Two things are wrong here:
- Pooled arrays are not zeroed, and the number of bytes written by
DeviceIoControlis ignored. The span covers the whole (larger-than-needed) array, soTryReadalways succeeds, even when the driver returned fewer bytes thansizeof(SymbolicLinkReparseBuffer)(20 bytes). Reparse points with little or no payload leave the remaining fields filled with leftovers of whatever previously used the pooled array. SymbolicLinkReparseBufferis a symlink-specific layout. ItsFlagsfield only exists for symlinks. For junctions (mount points), and for other tags, the same four bytes arePathBuffercontents or arbitrary data.
No wrong result is observable today, because the only consumer, DiskUtils.IsJunction, reads just ReparseTag, which is always in the first four bytes of a successful response. But the method is a trap for the next person who reads another field. It reads uninitialized (stale) data and returns a struct whose fields can be garbage while the method reports success.
Recommendations
- Capture
lpBytesReturnedand usenew Span<byte>(buffer, 0, (int)bytesReturned), so thatTryReadfails for a response that's too short. - Better: make the method return only what it can actually vouch for. Either return just the
ReparseTag(that's allIsJunctionneeds), or expose a header-only struct (ReparseTag,ReparseDataLength,Reserved) and parse the tag-specific part per tag. - Rename or document the struct accordingly, so it's clear that
Flagsis valid only forIO_REPARSE_TAG_SYMLINK.
- Langage dominant
- C#
- Étoiles
- 107
- Forks
- 22
- Merge moyen
- 3 j 2 h
- PR mergées (30 j)
- 13
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ForNeVeR/TruePath
-
Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemanticsPeut-être pris @ElectLive l’a pris il y a 2 jours. Ouvertebug good first issue help wanted
Difficulté 1/5 Moins d'une heure Accessibilité débutants 83/100
ForNeVeR/TruePath#241 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
AbsolutePath.ReadKind allocates a new 16 KiB buffer per directory on Windows: the pooled buffer is not returned on failurePeut-être pris @FalconTechDev l’a pris il y a 1 jour. Ouverteenhancement good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ForNeVeR/TruePath#240 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
ForNeVeR/TruePath#165 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Windows tests: symlink access requires dev mode or elevated accessPeut-être pris @hamdiakin l’a pris il y a 1 jour. Ouvertedocumentation help wanted
Difficulté 3/5 1-2 jours Accessibilité débutants 57/100
ForNeVeR/TruePath#245 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement help wanted
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de ForNeVeR/TruePath
Issues similaires
-
area-TableView bug needs-triage team-Controls
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
microsoft/microsoft-ui-xaml#12351 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
AudioClient and ImageClient file path overloads send the full local path as the multipart file namePeut-être pris @sebxt l’a pris aujourd’hui. Ouvertearea: audio area: images feature-request
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
openai/openai-dotnet#1453 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
Les mainteneurs répondent en général sous 1 jour
-
needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
elsa-workflows/elsa-foundation#3130 ·
Les mainteneurs répondent en général sous 1 jour
-
遥测历史查询始终返回 HTTP 400,页面静默无结果Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100