[Bug 1472324] [NEW] Error when using -o with relative filename

Eldon Olmstead eldon.olmstead at newnet.com
Tue Jul 7 15:58:06 UTC 2015


Public bug reported:

I am getting the following error when specifying a relative filename for output. 
patch -o ../test_file < ../empty.diff
patch: **** Can't create file ../test_file : Invalid cross-device link

The I have tried with real patch files and empty ones, the input file doesn't seem to matter the error only appears if I use '../' in the filename for -o.
When I use just -o without '..', patch works fine.

I don't know why the code is failing, but what ever it is trying to check for, the error message is misleading, since I am not crossing file systems. So either the error message needs to be fixed to describe the real issue, or relative filenames should be allowed here if they are still supposed to work. I see there are a number of  CVE patches, and that this bug was introduced when I updated to 
2.7.1-5ubuntu0.3 0.

According to gdb, the backtrace is that it is bailing out here:
Breakpoint 1, __GI_exit (status=status at entry=2) at exit.c:104
104     exit.c: No such file or directory.
(gdb) bt
#0  __GI_exit (status=status at entry=2) at exit.c:104
#1  0x0000000000406d7d in fatal_exit (sig=sig at entry=0) at patch.c:1984
#2  0x000000000040e083 in pfatal (format=format at entry=0x41934b "Can't create file %s") at util.c:962
#3  0x000000000040e3ce in create_file (file=0x628020 "../test_file", open_flags=<optimized out>, mode=384, to_dir_known_to_exist=<optimized out>)
    at util.c:573
#4  0x00000000004037ae in create_output_file (open_flags=<optimized out>, name=<optimized out>) at patch.c:1553
#5  open_outfile (name=<optimized out>) at patch.c:1575
#6  main (argc=6, argv=0x7fffffffd268) at patch.c:173


$ lsb_release -rd
Description:    Ubuntu 14.10
Release:        14.10

$ apt-cache policy patch
patch:
  Installed: 2.7.1-5ubuntu0.3
  Candidate: 2.7.1-5ubuntu0.3
  Version table:
 *** 2.7.1-5ubuntu0.3 0
        500 http://ca.archive.ubuntu.com/ubuntu/ utopic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ utopic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.7.1-5 0
        500 http://ca.archive.ubuntu.com/ubuntu/ utopic/main amd64 Packages

** Affects: patch (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to patch in Ubuntu.
https://bugs.launchpad.net/bugs/1472324

Title:
  Error when using -o with relative filename

Status in patch package in Ubuntu:
  New

Bug description:
  I am getting the following error when specifying a relative filename for output. 
  patch -o ../test_file < ../empty.diff
  patch: **** Can't create file ../test_file : Invalid cross-device link

  The I have tried with real patch files and empty ones, the input file doesn't seem to matter the error only appears if I use '../' in the filename for -o.
  When I use just -o without '..', patch works fine.

  I don't know why the code is failing, but what ever it is trying to check for, the error message is misleading, since I am not crossing file systems. So either the error message needs to be fixed to describe the real issue, or relative filenames should be allowed here if they are still supposed to work. I see there are a number of  CVE patches, and that this bug was introduced when I updated to 
  2.7.1-5ubuntu0.3 0.

  According to gdb, the backtrace is that it is bailing out here:
  Breakpoint 1, __GI_exit (status=status at entry=2) at exit.c:104
  104     exit.c: No such file or directory.
  (gdb) bt
  #0  __GI_exit (status=status at entry=2) at exit.c:104
  #1  0x0000000000406d7d in fatal_exit (sig=sig at entry=0) at patch.c:1984
  #2  0x000000000040e083 in pfatal (format=format at entry=0x41934b "Can't create file %s") at util.c:962
  #3  0x000000000040e3ce in create_file (file=0x628020 "../test_file", open_flags=<optimized out>, mode=384, to_dir_known_to_exist=<optimized out>)
      at util.c:573
  #4  0x00000000004037ae in create_output_file (open_flags=<optimized out>, name=<optimized out>) at patch.c:1553
  #5  open_outfile (name=<optimized out>) at patch.c:1575
  #6  main (argc=6, argv=0x7fffffffd268) at patch.c:173

  
  $ lsb_release -rd
  Description:    Ubuntu 14.10
  Release:        14.10

  $ apt-cache policy patch
  patch:
    Installed: 2.7.1-5ubuntu0.3
    Candidate: 2.7.1-5ubuntu0.3
    Version table:
   *** 2.7.1-5ubuntu0.3 0
          500 http://ca.archive.ubuntu.com/ubuntu/ utopic-updates/main amd64 Packages
          500 http://security.ubuntu.com/ubuntu/ utopic-security/main amd64 Packages
          100 /var/lib/dpkg/status
       2.7.1-5 0
          500 http://ca.archive.ubuntu.com/ubuntu/ utopic/main amd64 Packages

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/patch/+bug/1472324/+subscriptions



More information about the foundations-bugs mailing list