简体   繁体   English

Git 存储库的文件名中是否禁止使用 ɴᴜʟ 字符?

[英]Is the ɴᴜʟ character forbidden in filenames for Git repositories?

Without considering any implementation behaviour or host ᴏꜱ, are there by design, characters which aren't allowed in file or directory names?在不考虑任何实现行为或主机 ᴏꜱ 的情况下,是否存在设计上不允许出现在文件名或目录名中的字符?

I'm especially interested (considering Git is sometimes used as front-end) if the ᴀꜱᴄɪɪ ɴᴜʟ character is allowed.如果 ᴀꜱᴄɪɪ ɴᴜʟ 字符被允许,我特别感兴趣(考虑到 Git 有时被用作前端)
If this isn't allowed, can the attempt to create such file with rugged lead to remote code execution ?如果这是不允许的,尝试创建这样的文件是否会导致远程代码执行?

Yes.是的。 The index and tree objects both impose limitations due to their design:索引和树对象都因其设计而受到限制:

  1. A NUL cannot be in a path name. NUL不能在路径名中。 git uses null terminated strings to store filenames internally, both in the index and in tree objects . git 使用空终止字符串在内部存储文件名, 在索引树对象中

  2. A / cannot be in a filename, as it is the path separator in the index. /不能在文件名中,因为它是索引中的路径分隔符。

There are additional limitations imposed by Git clients, which are not part of the design of the data file formats: Git 客户端还施加了其他限制,这些限制不是数据文件格式设计的一部分:

  1. A path component cannot be named .git .路径组件不能命名为.git

  2. A path component may not be named .路径组件可能未命名. or .. , to prevent you from escaping your working directory... ,以防止您转义您的工作目录。

  3. If core.protectHFS is set, then when all zero-width Unicode characters are removed from a path component, the remainder may not be .git .如果设置了core.protectHFS ,那么当从路径组件中删除所有零宽度 Unicode 字符时,剩余部分可能不是.git

  4. If core.protectNTFS is set, then a path component may not be GIT~1 , .git\\ or .git followed by trailing spaces or dots.如果设置了core.protectNTFS ,则路径组件可能不是GIT~1.git\\.git后跟尾随空格或点。

And no, you cannot create those with libgit2 either, because it also uses null terminated strings to store paths.不,你也不能用 libgit2 创建那些,因为也使用空终止字符串来存储路径。 It seems unlikely that there's a buffer overrun potential here (if anything, you would expect a buffer underrun).这里似乎不太可能存在缓冲区溢出的可能性(如果有的话,您会期望缓冲区溢出)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM