14
inaba
8d

So I'm making a file uploader for a buddy of mine and I got an error that I had never seen before. Suddenly I had C++ code and some other weird shite in my terminal. Turns our that I got a memory leak and the first thing that sprung to mind was "Fuck yes, I get to do some NCIS ass debugging".

Now the app worked fine for smaller files, like 5MB - 10MB files, but when I tried with some Linux ISO's it would produce the memory leak.

Well I opened the app with --inspect and set some breakpoints and after setting some breakpoints I found it. Now, for this app I needed to do some things if the user uploads an already existing file. Now to do that I decided to take the SHA string of the file and store it in a database. To do this I used fs.readFile aaaaaaaaaand this is where it went wrong. fs.readFile doesn't read the file as a stream.

Well when I found that, boy did I feel stupid :v

Comments
  • 4
    But at least, now you know 👍😃
  • 3
    Don't feel bad.
    Many file operations differ between versions of Node, especially checking if a file exists. I don't think that one has ever remained unchanged.
  • 0
    @karma learning like this is the best 😊

    @Root yeah but still, I feel a bit silly :p
  • 0
    Congratulations, you successfully breached the first of 9 NCIS main frame firewalls.

    Yes. I do remember this NCIS episode where the NCIS chief was led by the NCIS hackerman to prevent the NCIS from being hacked by a botnet.
    A countdown had shown the remaining time till every bit of data would be erased forever since there is no backup system.

    xD
  • 1
    @TylerDDevRant Let me guess, at the end they stop the hacking baddie thingy deathy oopsie doopsie, and the countdown stops on 00:03.
    General sight of relief, nobody realizing that the great majority of the data has already been destroyed and that the remains are certainly just corrupted garbage at this point.
    Then, they all just go out to take a drink, while the head of department, that mysterious and hurt man with a sad past, stays at the office to ponder some deep and insightful lesson he took today, a half smile on his face...
    Yet no one wonders if the security hole has been fixed or if it would be a good idea to set up some backup for goverment sensible data...
  • 0
    @Brosyl
    Wow, what an awesome reply!
    Thanks for your time, dude.

    Yeah. Kind of.
    But as they claimed that there was not a single byte manipulated, because of the most heroic act of the glorious NCIS team.

    Damn! These guys are one of a kind ^^
Your Job Suck?
Get a Better Job
Add Comment