Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
if(!-w $mp3_file) { # This shouldn't happen but... chmod 0755,$mp3_file; }

Why do you try to make an MP3 file world executable if you can't read it? And why do you make it readable for group and world? Why do you even think about changing the mode of files that are not writeable?

There are usually good reasons for chmod -w somefile and chmod go-rw somefile: I don't want to accidentally modify a file in the first case, and I don't want others to read my files in the second case. Your hardcoded chmod 0755 ignores both. To make things worse, it sets the executable flag, possibly creating a new vulnerability.

I won't start with race conditions between stat (implied in -w) and open, because MP3::Tag has the same problem, so your code does not make it worse in this special case. Generally, one should not try to predict if open fails or succeeds by using stat. It can't work reliably (race condition), and it is not needed. open sets errno a.k.a. $! on error, and errno delivers sufficient information why open failed.


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: I need help about MP3::Tag and perl script. by afoken
in thread I need help about MP3::Tag and perl script. by osmy

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (7)
    As of 2018-04-26 19:48 GMT
    Find Nodes?
      Voting Booth?