{"thread":{"id":"56326","subject":"Git Modifying DLL","startedAt":"2021-08-19T17:58:45Z","lastAt":"2021-09-01T21:07:15Z","messageCount":9,"participants":["Jonathon Anderson","Randall S. Becker","Torsten Bögershausen","Jeff King","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"433140","messageId":"CAG83euoGmVUUBh00wAEX1muZogNPOQUV6+ppL8x8qCaDnzTbDw@mail.gmail.com","threadId":"56326","inReplyTo":null,"subject":"Git Modifying DLL","fromName":"Jonathon Anderson","fromEmail":"janderson@acesquality.com","sentAt":"2021-08-19T17:58:30Z","receivedAt":"2021-08-19T17:58:45Z","isPatch":false,"sender":{"key":"janderson@acesquality.com","avatar":null},"body":"I'm having an issue with git modifying a DLL file and corrupting it.\nWhen I download the original working file, it has a hash starting with\n8FE400... I then commit the DLL and push it to our repo. When I\ndownload the file from the repo, the DLL can't be loaded, and it has a\nhash starting with E004FB...\n\nOpening the DLL in a hex editor and using the compare feature, there's\na single change to the file. In the original, the byte code starting\nat 0x0074 is 2E 0D 0D 0A 24.\nIn the git file, the byte code starting at 0x0074 is 2E 0D 0A 24\n\nA single carriage return character (0x0D) has been removed, and the\nfile size has changed from 260,608 bytes to 260,607 bytes.\n\nI ruled out the possibility that the repo server was doing anything to\nthe file because I deleted the file in my local repository then ran\n\"git reset --hard HEAD\" to restore the file, and the hash had once\nagain changed to E004FB...\n\nOS: Windows 10.0.19043 pro\ngit: 2.32.0.windows.1\n\nI have no settings configured for git behavior handling line endings.\n\nThe original DLL can be found here:\nhttps://www.powershellgallery.com/packages/PSWindowsUpdate/2.1.1.2\n\nNavigate to \"Manual Download\", download the nuget package and unzip\nit. The file is PSWindowsUpdate.dll\n\nThank you,\nJonathon\n"},{"id":"433143","messageId":"010f01d79525$f10a1f60$d31e5e20$@nexbridge.com","threadId":"56326","inReplyTo":"CAG83euoGmVUUBh00wAEX1muZogNPOQUV6+ppL8x8qCaDnzTbDw@mail.gmail.com","subject":"RE: Git Modifying DLL","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2021-08-19T18:13:36Z","receivedAt":"2021-08-19T18:13:51Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On August 19, 2021 1:59 PM, Jonathon Anderson wrote:\n>\n>I'm having an issue with git modifying a DLL file and corrupting it.\n>When I download the original working file, it has a hash starting with 8FE400... I then commit the DLL and push it to our repo. When I\n>download the file from the repo, the DLL can't be loaded, and it has a hash starting with E004FB...\n>\n>Opening the DLL in a hex editor and using the compare feature, there's a single change to the file. In the original, the byte code starting\n>at 0x0074 is 2E 0D 0D 0A 24.\n>In the git file, the byte code starting at 0x0074 is 2E 0D 0A 24\n>\n>A single carriage return character (0x0D) has been removed, and the file size has changed from 260,608 bytes to 260,607 bytes.\n>\n>I ruled out the possibility that the repo server was doing anything to the file because I deleted the file in my local repository then ran \"git\n>reset --hard HEAD\" to restore the file, and the hash had once again changed to E004FB...\n>\n>OS: Windows 10.0.19043 pro\n>git: 2.32.0.windows.1\n>\n>I have no settings configured for git behavior handling line endings.\n>\n>The original DLL can be found here:\n>https://www.powershellgallery.com/packages/PSWindowsUpdate/2.1.1.2\n>\n>Navigate to \"Manual Download\", download the nuget package and unzip it. The file is PSWindowsUpdate.dll\n\nHave you set up an entry for *.dll as binary in your .gitattributes file?\n\n-Randall\n\n"},{"id":"433144","messageId":"CAG83euo2B4QFU_S6Yqd3UACWq63p=L+T30CwzT52D8H=S5pRVg@mail.gmail.com","threadId":"56326","inReplyTo":"010f01d79525$f10a1f60$d31e5e20$@nexbridge.com","subject":"Re: Git Modifying DLL","fromName":"Jonathon Anderson","fromEmail":"janderson@acesquality.com","sentAt":"2021-08-19T18:21:03Z","receivedAt":"2021-08-19T18:21:18Z","isPatch":false,"sender":{"key":"janderson@acesquality.com","avatar":null},"body":"I had not. I tested that and it worked. I assumed that git would\nautomatically treat dll files as binary. Thanks for the help!\n\nOn Thu, Aug 19, 2021 at 1:13 PM Randall S. Becker\n<rsbecker@nexbridge.com> wrote:\n>\n> On August 19, 2021 1:59 PM, Jonathon Anderson wrote:\n> >\n> >I'm having an issue with git modifying a DLL file and corrupting it.\n> >When I download the original working file, it has a hash starting with 8FE400... I then commit the DLL and push it to our repo. When I\n> >download the file from the repo, the DLL can't be loaded, and it has a hash starting with E004FB...\n> >\n> >Opening the DLL in a hex editor and using the compare feature, there's a single change to the file. In the original, the byte code starting\n> >at 0x0074 is 2E 0D 0D 0A 24.\n> >In the git file, the byte code starting at 0x0074 is 2E 0D 0A 24\n> >\n> >A single carriage return character (0x0D) has been removed, and the file size has changed from 260,608 bytes to 260,607 bytes.\n> >\n> >I ruled out the possibility that the repo server was doing anything to the file because I deleted the file in my local repository then ran \"git\n> >reset --hard HEAD\" to restore the file, and the hash had once again changed to E004FB...\n> >\n> >OS: Windows 10.0.19043 pro\n> >git: 2.32.0.windows.1\n> >\n> >I have no settings configured for git behavior handling line endings.\n> >\n> >The original DLL can be found here:\n> >https://www.powershellgallery.com/packages/PSWindowsUpdate/2.1.1.2\n> >\n> >Navigate to \"Manual Download\", download the nuget package and unzip it. The file is PSWindowsUpdate.dll\n>\n> Have you set up an entry for *.dll as binary in your .gitattributes file?\n>\n> -Randall\n>\n"},{"id":"433230","messageId":"20210820153756.c7b2d5zju7mkf4w5@tb-raspi4","threadId":"56326","inReplyTo":"CAG83euo2B4QFU_S6Yqd3UACWq63p=L+T30CwzT52D8H=S5pRVg@mail.gmail.com","subject":"Re: Git Modifying DLL","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2021-08-20T15:37:56Z","receivedAt":"2021-08-20T15:38:17Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"First of all, thanks for the report.\n(And please, no top-posting in this list, see my comments at the end)\n\nOn Thu, Aug 19, 2021 at 01:21:03PM -0500, Jonathon Anderson wrote:\n> I had not. I tested that and it worked. I assumed that git would\n> automatically treat dll files as binary. Thanks for the help!\n>\n> On Thu, Aug 19, 2021 at 1:13 PM Randall S. Becker\n> <rsbecker@nexbridge.com> wrote:\n> >\n> > On August 19, 2021 1:59 PM, Jonathon Anderson wrote:\n> > >\n> > >I'm having an issue with git modifying a DLL file and corrupting it.\n> > >When I download the original working file, it has a hash starting with 8FE400... I then commit the DLL and push it to our repo. When I\n> > >download the file from the repo, the DLL can't be loaded, and it has a hash starting with E004FB...\n> > >\n> > >Opening the DLL in a hex editor and using the compare feature, there's a single change to the file. In the original, the byte code starting\n> > >at 0x0074 is 2E 0D 0D 0A 24.\n> > >In the git file, the byte code starting at 0x0074 is 2E 0D 0A 24\n> > >\n> > >A single carriage return character (0x0D) has been removed, and the file size has changed from 260,608 bytes to 260,607 bytes.\n> > >\n> > >I ruled out the possibility that the repo server was doing anything to the file because I deleted the file in my local repository then ran \"git\n> > >reset --hard HEAD\" to restore the file, and the hash had once again changed to E004FB...\n> > >\n> > >OS: Windows 10.0.19043 pro\n> > >git: 2.32.0.windows.1\n> > >\n> > >I have no settings configured for git behavior handling line endings.\n> > >\n> > >The original DLL can be found here:\n> > >https://www.powershellgallery.com/packages/PSWindowsUpdate/2.1.1.2\n> > >\n> > >Navigate to \"Manual Download\", download the nuget package and unzip it. The file is PSWindowsUpdate.dll\n> >\n> > Have you set up an entry for *.dll as binary in your .gitattributes file?\n> >\n> > -Randall\n> >\n\nI downloaded the dll.\n\nI can not reproduce the issue here - so I wonder, what is going on.\n\nCould you run the following experiment, please ?\n(in git bash or so)\n\nmkdir  dlltest\ncd dlltest\ngit init\ncp whereveritis/PSWindowsUpdate.dll .\n\ngit ls-files -o --eol\n\n# I get\ngit ls-files --eol -o PSWindowsUpdate.dll\ni/      w/-text attr/\t\t\tPSWindowsUpdate.dll\n\nThis means, that the file is \"classified\" as \"-text\" in the working tree.\n\"-text\" means the same as binary.\nAnd git should not change CRLF at all.\n\nDo you have any more .gitattributes in you repo?\nOf course, you can run the command inside your repo.\nOmit the \"-o\" for other and simply run\ngit ls-files --eol\n\n\n"},{"id":"433263","messageId":"YR/tyHWQ6+2sP2iA@coredump.intra.peff.net","threadId":"56326","inReplyTo":"CAG83euo2B4QFU_S6Yqd3UACWq63p=L+T30CwzT52D8H=S5pRVg@mail.gmail.com","subject":"Re: Git Modifying DLL","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-08-20T18:00:40Z","receivedAt":"2021-08-20T18:00:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 19, 2021 at 01:21:03PM -0500, Jonathon Anderson wrote:\n\n> I had not. I tested that and it worked. I assumed that git would\n> automatically treat dll files as binary. Thanks for the help!\n\nGit doesn't know about any file extensions by default. Its default \"is\nit binary\" test looks for NUL bytes in the first 8k or so of the file.\nI'd expect your DLL would probably have such a NUL byte.\n\nIs it possible you have other .gitattributes set which are confusing\nthings?\n\nYou might try:\n\n  git check-attr --all <path>\n\nor:\n\n  git ls-files --stdin | git check-attr --stdin --all\n\n-Peff\n"},{"id":"433270","messageId":"CAG83euofNXHx8-=7Obj-Ju5U_fjwNBuLVJjmccVhe9bqRFyBiw@mail.gmail.com","threadId":"56326","inReplyTo":"YR/tyHWQ6+2sP2iA@coredump.intra.peff.net","subject":"Re: Git Modifying DLL","fromName":"Jonathon Anderson","fromEmail":"janderson@acesquality.com","sentAt":"2021-08-20T18:47:02Z","receivedAt":"2021-08-20T18:47:18Z","isPatch":false,"sender":{"key":"janderson@acesquality.com","avatar":null},"body":"On Fri, Aug 20, 2021 at 1:00 PM Jeff King <peff@peff.net> wrote:\n>\n> On Thu, Aug 19, 2021 at 01:21:03PM -0500, Jonathon Anderson wrote:\n>\n> > I had not. I tested that and it worked. I assumed that git would\n> > automatically treat dll files as binary. Thanks for the help!\n>\n> Git doesn't know about any file extensions by default. Its default \"is\n> it binary\" test looks for NUL bytes in the first 8k or so of the file.\n> I'd expect your DLL would probably have such a NUL byte.\n>\n> Is it possible you have other .gitattributes set which are confusing\n> things?\n>\n> You might try:\n>\n>   git check-attr --all <path>\n>\n> or:\n>\n>   git ls-files --stdin | git check-attr --stdin --all\n>\n> -Peff\n\nWhen I remove '*.dll binary\" from .gitattributes, I get this:\n\n$ git check-attr --all ./PSWindowsUpdate.dll\n./PSWindowsUpdate.dll: text: set\n./PSWindowsUpdate.dll: eol: lf\n\n\n\nWhen I add \"*.dll binary\" to .gitattributes, I get this:\n\n$ git check-attr --all ./PSWindowsUpdate.dll\n./PSWindowsUpdate.dll: binary: set\n./PSWindowsUpdate.dll: diff: unset\n./PSWindowsUpdate.dll: merge: unset\n./PSWindowsUpdate.dll: text: unset\n./PSWindowsUpdate.dll: eol: lf\n\n\nI can also confirm that there are null bytes in the first 8k bytes.\nThese are the first 16 bytes\n\n4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00\n\nThanks,\nJonathon\n"},{"id":"433271","messageId":"YR//IDB9ml5RO2H6@camp.crustytoothpaste.net","threadId":"56326","inReplyTo":"CAG83euofNXHx8-=7Obj-Ju5U_fjwNBuLVJjmccVhe9bqRFyBiw@mail.gmail.com","subject":"Re: Git Modifying DLL","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-08-20T19:14:40Z","receivedAt":"2021-08-20T19:14:47Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-08-20 at 18:47:02, Jonathon Anderson wrote:\n> On Fri, Aug 20, 2021 at 1:00 PM Jeff King <peff@peff.net> wrote:\n> >\n> > On Thu, Aug 19, 2021 at 01:21:03PM -0500, Jonathon Anderson wrote:\n> >\n> > > I had not. I tested that and it worked. I assumed that git would\n> > > automatically treat dll files as binary. Thanks for the help!\n> >\n> > Git doesn't know about any file extensions by default. Its default \"is\n> > it binary\" test looks for NUL bytes in the first 8k or so of the file.\n> > I'd expect your DLL would probably have such a NUL byte.\n> >\n> > Is it possible you have other .gitattributes set which are confusing\n> > things?\n> >\n> > You might try:\n> >\n> >   git check-attr --all <path>\n> >\n> > or:\n> >\n> >   git ls-files --stdin | git check-attr --stdin --all\n> >\n> > -Peff\n> \n> When I remove '*.dll binary\" from .gitattributes, I get this:\n> \n> $ git check-attr --all ./PSWindowsUpdate.dll\n> ./PSWindowsUpdate.dll: text: set\n> ./PSWindowsUpdate.dll: eol: lf\n\nYes, this is definitely not correct.  The flag \"text\" being set tells\nGit to do line-ending conversion and \"eol=lf\" says to convert line\nendings into LF.\n\nYou should look for things in your .gitattributes file that say\nsomething like \"* text\", which you probably don't want.  You could use\n\"* text=auto\", which should be fine for most cases, though.  It's also\npossible those aren't in a .gitattributes file in your repository but\none elsewhere on your system.  You can check gitattributes(5) for the\nlocations of other files that can affect it.\n\nAs a note, it is best practice not to check binary dependencies or build\nartifacts into the repo.  Those are best stored elsewhere, such as an\nartifact server.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"433274","messageId":"01a101d795fc$ca46e520$5ed4af60$@nexbridge.com","threadId":"56326","inReplyTo":"YR//IDB9ml5RO2H6@camp.crustytoothpaste.net","subject":"RE: Git Modifying DLL","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2021-08-20T19:51:33Z","receivedAt":"2021-08-20T19:51:56Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On August 20, 2021 3:15 PM, brian m. carlson wrote:\n>On 2021-08-20 at 18:47:02, Jonathon Anderson wrote:\n>> On Fri, Aug 20, 2021 at 1:00 PM Jeff King <peff@peff.net> wrote:\n>> >\n>> > On Thu, Aug 19, 2021 at 01:21:03PM -0500, Jonathon Anderson wrote:\n>> >\n>> > > I had not. I tested that and it worked. I assumed that git would\n>> > > automatically treat dll files as binary. Thanks for the help!\n>> >\n>> > Git doesn't know about any file extensions by default. Its default\n>> > \"is it binary\" test looks for NUL bytes in the first 8k or so of the file.\n>> > I'd expect your DLL would probably have such a NUL byte.\n>> >\n>> > Is it possible you have other .gitattributes set which are confusing\n>> > things?\n>> >\n>> > You might try:\n>> >\n>> >   git check-attr --all <path>\n>> >\n>> > or:\n>> >\n>> >   git ls-files --stdin | git check-attr --stdin --all\n>> >\n>> > -Peff\n>>\n>> When I remove '*.dll binary\" from .gitattributes, I get this:\n>>\n>> $ git check-attr --all ./PSWindowsUpdate.dll\n>> ./PSWindowsUpdate.dll: text: set\n>> ./PSWindowsUpdate.dll: eol: lf\n>\n>Yes, this is definitely not correct.  The flag \"text\" being set tells Git to do line-ending conversion and \"eol=lf\" says to convert line endings\n>into LF.\n>\n>You should look for things in your .gitattributes file that say something like \"* text\", which you probably don't want.  You could use\n>\"* text=auto\", which should be fine for most cases, though.  It's also possible those aren't in a .gitattributes file in your repository but one\n>elsewhere on your system.  You can check gitattributes(5) for the locations of other files that can affect it.\n>\n>As a note, it is best practice not to check binary dependencies or build artifacts into the repo.  Those are best stored elsewhere, such as an\n>artifact server.\n\nOT: Unless you are using git as an artifact repository to retain the dependency relationship between objects and the source commits that built them for PCI and SWIFT compliance. git is exceptional when it comes to evidence-of-origin forensics of specific installation artifacts when release structures are more complex than \"deploy everything\" use cases. But that may be a discussion we can have elsewhere.\n\nJust my $20.00.\n-Randall\n\n"},{"id":"434472","messageId":"CAG83euoQW=HHN-cSJc3pOzsYUMEmJ0=9o2+zymm-z5e=b1SXjA@mail.gmail.com","threadId":"56326","inReplyTo":"01a101d795fc$ca46e520$5ed4af60$@nexbridge.com","subject":"Re: Git Modifying DLL","fromName":"Jonathon Anderson","fromEmail":"janderson@acesquality.com","sentAt":"2021-09-01T21:07:00Z","receivedAt":"2021-09-01T21:07:15Z","isPatch":false,"sender":{"key":"janderson@acesquality.com","avatar":null},"body":"So, I somehow didn't realize what this was when I was looking at it,\nbut this is the first line in our .gitattributes\n\n* text eol=lf\n\nIt all makes sense now.\n\nAnd, yea, we're using git to retain dependency relationships and bring\nthose files under version control so we can audit changes and go\nthrough the full peer review process, etc\n\nOn Fri, Aug 20, 2021 at 2:51 PM Randall S. Becker\n<rsbecker@nexbridge.com> wrote:\n>\n> On August 20, 2021 3:15 PM, brian m. carlson wrote:\n> >On 2021-08-20 at 18:47:02, Jonathon Anderson wrote:\n> >> On Fri, Aug 20, 2021 at 1:00 PM Jeff King <peff@peff.net> wrote:\n> >> >\n> >> > On Thu, Aug 19, 2021 at 01:21:03PM -0500, Jonathon Anderson wrote:\n> >> >\n> >> > > I had not. I tested that and it worked. I assumed that git would\n> >> > > automatically treat dll files as binary. Thanks for the help!\n> >> >\n> >> > Git doesn't know about any file extensions by default. Its default\n> >> > \"is it binary\" test looks for NUL bytes in the first 8k or so of the file.\n> >> > I'd expect your DLL would probably have such a NUL byte.\n> >> >\n> >> > Is it possible you have other .gitattributes set which are confusing\n> >> > things?\n> >> >\n> >> > You might try:\n> >> >\n> >> >   git check-attr --all <path>\n> >> >\n> >> > or:\n> >> >\n> >> >   git ls-files --stdin | git check-attr --stdin --all\n> >> >\n> >> > -Peff\n> >>\n> >> When I remove '*.dll binary\" from .gitattributes, I get this:\n> >>\n> >> $ git check-attr --all ./PSWindowsUpdate.dll\n> >> ./PSWindowsUpdate.dll: text: set\n> >> ./PSWindowsUpdate.dll: eol: lf\n> >\n> >Yes, this is definitely not correct.  The flag \"text\" being set tells Git to do line-ending conversion and \"eol=lf\" says to convert line endings\n> >into LF.\n> >\n> >You should look for things in your .gitattributes file that say something like \"* text\", which you probably don't want.  You could use\n> >\"* text=auto\", which should be fine for most cases, though.  It's also possible those aren't in a .gitattributes file in your repository but one\n> >elsewhere on your system.  You can check gitattributes(5) for the locations of other files that can affect it.\n> >\n> >As a note, it is best practice not to check binary dependencies or build artifacts into the repo.  Those are best stored elsewhere, such as an\n> >artifact server.\n>\n> OT: Unless you are using git as an artifact repository to retain the dependency relationship between objects and the source commits that built them for PCI and SWIFT compliance. git is exceptional when it comes to evidence-of-origin forensics of specific installation artifacts when release structures are more complex than \"deploy everything\" use cases. But that may be a discussion we can have elsewhere.\n>\n> Just my $20.00.\n> -Randall\n>\n"}]}