Why some file headers have a magic number [on hold]











up vote
1
down vote

favorite












Some files like PNG and GIF have a magic number in the file header. It is used to "identify the file" as a specific type like PNG. You just check the magic number and that tells you the type. But I don't understand why you would need this because it can be spoofed so easily and nobody is ever going to look at the file and read it I would suppose. It seems if you just assumed it was a specific mime-type and then it either worked or it didn't work, that would be just as effective.










share|improve this question













put on hold as unclear what you're asking by Romeo Ninov, schily, mosvy, RalfFriedl, Thomas Nov 22 at 20:03


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 5




    I suppose it is the same as labeling it .pdf or .mp4 , it automates recognition by the os, it is a convenience convention not necessarily a security feature
    – Panther
    Nov 22 at 16:44















up vote
1
down vote

favorite












Some files like PNG and GIF have a magic number in the file header. It is used to "identify the file" as a specific type like PNG. You just check the magic number and that tells you the type. But I don't understand why you would need this because it can be spoofed so easily and nobody is ever going to look at the file and read it I would suppose. It seems if you just assumed it was a specific mime-type and then it either worked or it didn't work, that would be just as effective.










share|improve this question













put on hold as unclear what you're asking by Romeo Ninov, schily, mosvy, RalfFriedl, Thomas Nov 22 at 20:03


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 5




    I suppose it is the same as labeling it .pdf or .mp4 , it automates recognition by the os, it is a convenience convention not necessarily a security feature
    – Panther
    Nov 22 at 16:44













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Some files like PNG and GIF have a magic number in the file header. It is used to "identify the file" as a specific type like PNG. You just check the magic number and that tells you the type. But I don't understand why you would need this because it can be spoofed so easily and nobody is ever going to look at the file and read it I would suppose. It seems if you just assumed it was a specific mime-type and then it either worked or it didn't work, that would be just as effective.










share|improve this question













Some files like PNG and GIF have a magic number in the file header. It is used to "identify the file" as a specific type like PNG. You just check the magic number and that tells you the type. But I don't understand why you would need this because it can be spoofed so easily and nobody is ever going to look at the file and read it I would suppose. It seems if you just assumed it was a specific mime-type and then it either worked or it didn't work, that would be just as effective.







files






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 16:34









Lance Pollard

1447




1447




put on hold as unclear what you're asking by Romeo Ninov, schily, mosvy, RalfFriedl, Thomas Nov 22 at 20:03


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by Romeo Ninov, schily, mosvy, RalfFriedl, Thomas Nov 22 at 20:03


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 5




    I suppose it is the same as labeling it .pdf or .mp4 , it automates recognition by the os, it is a convenience convention not necessarily a security feature
    – Panther
    Nov 22 at 16:44














  • 5




    I suppose it is the same as labeling it .pdf or .mp4 , it automates recognition by the os, it is a convenience convention not necessarily a security feature
    – Panther
    Nov 22 at 16:44








5




5




I suppose it is the same as labeling it .pdf or .mp4 , it automates recognition by the os, it is a convenience convention not necessarily a security feature
– Panther
Nov 22 at 16:44




I suppose it is the same as labeling it .pdf or .mp4 , it automates recognition by the os, it is a convenience convention not necessarily a security feature
– Panther
Nov 22 at 16:44










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Files in linux don't always have a .exe or .png extention at the end of them, like windows requires? So to mitigate that, the magic number is used to help id the file type and open it properly. This is originaly a unix thing that found it's way into linux because it's useful and habit, on the side of the coders.






share|improve this answer








New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2




    Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
    – Kusalananda
    Nov 22 at 17:22












  • Absolutly right! @Kusalananda
    – Michael Prokopec
    Nov 22 at 17:30


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Files in linux don't always have a .exe or .png extention at the end of them, like windows requires? So to mitigate that, the magic number is used to help id the file type and open it properly. This is originaly a unix thing that found it's way into linux because it's useful and habit, on the side of the coders.






share|improve this answer








New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2




    Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
    – Kusalananda
    Nov 22 at 17:22












  • Absolutly right! @Kusalananda
    – Michael Prokopec
    Nov 22 at 17:30















up vote
0
down vote













Files in linux don't always have a .exe or .png extention at the end of them, like windows requires? So to mitigate that, the magic number is used to help id the file type and open it properly. This is originaly a unix thing that found it's way into linux because it's useful and habit, on the side of the coders.






share|improve this answer








New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2




    Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
    – Kusalananda
    Nov 22 at 17:22












  • Absolutly right! @Kusalananda
    – Michael Prokopec
    Nov 22 at 17:30













up vote
0
down vote










up vote
0
down vote









Files in linux don't always have a .exe or .png extention at the end of them, like windows requires? So to mitigate that, the magic number is used to help id the file type and open it properly. This is originaly a unix thing that found it's way into linux because it's useful and habit, on the side of the coders.






share|improve this answer








New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









Files in linux don't always have a .exe or .png extention at the end of them, like windows requires? So to mitigate that, the magic number is used to help id the file type and open it properly. This is originaly a unix thing that found it's way into linux because it's useful and habit, on the side of the coders.







share|improve this answer








New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Nov 22 at 16:44









Michael Prokopec

47213




47213




New contributor




Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
    – Kusalananda
    Nov 22 at 17:22












  • Absolutly right! @Kusalananda
    – Michael Prokopec
    Nov 22 at 17:30














  • 2




    Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
    – Kusalananda
    Nov 22 at 17:22












  • Absolutly right! @Kusalananda
    – Michael Prokopec
    Nov 22 at 17:30








2




2




Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
– Kusalananda
Nov 22 at 17:22






Also, a library can immediately reject a file that has the wrong signature instead of failing at a later stage when the data does not conform to the expected specification. This is regardless of operating system. Almost any type of data specification specifies a way of identifying the data by means of some sort of signature.
– Kusalananda
Nov 22 at 17:22














Absolutly right! @Kusalananda
– Michael Prokopec
Nov 22 at 17:30




Absolutly right! @Kusalananda
– Michael Prokopec
Nov 22 at 17:30



Popular posts from this blog

サソリ

広島県道265号伴広島線

Setup Asymptote in Texstudio