tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/39002: harmful AWK extension: non-portable escaped character



 >>> inside a string. It's not clearly defined there at all.
 >>
 >> ...which is why it ought to generate a warning.

> No, I don't think so.
...
> Adding a warning, especially in the way that was proposed (IIUC), will
> potentially make many valid scripts, including existing scripts, spew
> unnecessary warnings.
Yet another touches to the picture.
I've found the following because I use proposed patch on my own system.

NetBSD installation process.

  0 src>sudo /srv/obj/destdir.i386/usr/sbin/postinstall -s /srv/src -d / fix 
defaults mtree obsolete 
  Source directory: /srv/src
  Target directory: /
  defaults fix:
  mtree fix:
  obsolete fix:
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 33
   context is
                          checklib(minor, $0, >>>  "^lib.*\. <<< so\.")
  awk: non-terminated string ^lib.*.      el... at source line 35
  awk: syntax error at source line 36
  awk: illegal statement at source line 36
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: giving up
   source line number 53
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 33
   context is
                          checklib(minor, $0, >>>  "^lib.*\. <<< so\.")
  awk: non-terminated string ^lib.*.      el... at source line 35
  awk: syntax error at source line 36
  awk: illegal statement at source line 36
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: giving up
   source line number 53
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 33
   context is
                          checklib(minor, $0, >>>  "^lib.*\. <<< so\.")
  awk: non-terminated string ^lib.*.      el... at source line 35
  awk: syntax error at source line 36
  awk: illegal statement at source line 36
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: giving up
   source line number 53
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 33
   context is
                          checklib(minor, $0, >>>  "^lib.*\. <<< so\.")
  awk: non-terminated string ^lib.*.      el... at source line 35
  awk: syntax error at source line 36
  awk: illegal statement at source line 36
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: warning: escape sequence \`.' treated as plain `.'
   source line number 42
  awk: giving up
   source line number 53
  postinstall fixes passed: defaults mtree obsolete
  postinstall fixes failed:
  0 src>



Now lets look to the code.

usr.sbin/postinstall/postinstall:

    470 function checklib(results, line, regex) {
                                         ^^^^^
    ...
    495 /^lib.*\.so\.[0-9]+\.[0-9]+(\.[0-9]+)?$/ {
    496         if (AllLibs)
    497                 checklib(minor, $0, "^lib.*\.so\.")
                                            ^^^^^^^^^^^^^^
    498         else
    499                 checklib(found, $0, "^lib.*\.so\.[0-9]+\.")
                                            ^^^^^^^^^^^^^^^^^^^^^^
    500 }
    ...
    503         if (AllLibs)
    504                 checklib(major, $0, "^lib.*\.so\.")
    505 }

I think you understand that constant string '^lib.*\.so\.'
becomes regexp '^lib.*.so.' and '^lib.*\.so\.[0-9]+\.' becomes
'^lib.*.so.[0-9]+.' . When author wrote this, I believe he wanted
to write different things ;-)

Please fix this buggy awk code in postinstall script which is run by
EVERY NetBSD user for many years.

This extension is really dangerous.

-- 
Best regards, Aleksey Cheusov.


Home | Main Index | Thread Index | Old Index