Keepass2 puts incorrect atom in clipboard targets list

Bug #1379877 reported by trespasserw
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
keepass2 (Ubuntu)
Confirmed
Undecided
Unassigned
xsel (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

On copying a password or entry into a clipboard Keepass2 puts an atom with id of zero into a list of formats. This makes it impossible to paste from Keepass2 into any Java program.

Following is a simple Java program which attempts to print clipboard content:
=== ClipRead.java ===
import java.awt.*;
import java.awt.datatransfer.*;

public class ClipRead {
  public static void main(String... args) throws Exception {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    Object data = clipboard.getData(DataFlavor.stringFlavor);
    System.out.println("[" + data + "]");
  }
}
=== ClipRead.java ===

Calling it after copying from Keepass2 results in a following exception:
$ java ClipRead
Atom was 0
Exception in thread "main" java.lang.NullPointerException: Failed to retrieve atom name.
 at sun.awt.X11.XlibWrapper.XGetAtomName(Native Method)
 at sun.awt.X11.XAtom.getName(XAtom.java:186)
 at sun.awt.X11.XDataTransferer.getTargetNameForAtom(XDataTransferer.java:164)
 at sun.awt.X11.XDataTransferer.getNativeForFormat(XDataTransferer.java:153)
 at sun.awt.datatransfer.DataTransferer.getFlavorsForFormats(DataTransferer.java:735)
 at sun.awt.datatransfer.SunClipboard.getData(SunClipboard.java:218)
 at ClipRead.main(ClipRead.java:8)

Expected result:
$ java ClipRead
[my password]

Revision history for this message
Julian Taylor (jtaylor) wrote :

do you have xsel installed? the builtin clipboard of mono which is used without xsel installed is know to have issues.

Revision history for this message
trespasserw (trespasserw) wrote :

No, I don't. Will try it next week, thanks.

Revision history for this message
trespasserw (trespasserw) wrote :

BTW does Keepass2 use gtk-sharp? Gtk.Clipboard seemed to work fine (at least in my tests).

Revision history for this message
Julian Taylor (jtaylor) wrote :

no keepass uses monos reimplementation of winforms which is the source of pretty much all bugs as it is terrible and unmaintained.
keepassx is a frontend to keepass databases that has a more native gui. I think its based on Qt. But i'm unfamiliar with how far its version 2 database support is.

Revision history for this message
trespasserw (trespasserw) wrote :

Well, it turned out to be xsel's problem - it corrupts the clipboard the same way when called manually.

Revision history for this message
trespasserw (trespasserw) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in keepass2 (Ubuntu):
status: New → Confirmed
Changed in xsel (Ubuntu):
status: New → Confirmed
Revision history for this message
Colan Schwartz (colan) wrote :

@trespasserw: The above URL returns a 404. Has it moved, been deleted, or is it no longer a public project?

Revision history for this message
Colan Schwartz (colan) wrote :

Workaround: Use KeePassX in these situations as both applications can share the same database.

Revision history for this message
trespasserw (trespasserw) wrote :

@colan the PR was accepted so I have dropped my fork. The commit is here: https://github.com/kfish/xsel/commit/05f6172dc030bc81cda795e7f5e8cb351bc01ecc

Revision history for this message
Colan Schwartz (colan) wrote :

Thanks, but I've recently switched to https://keepassxc.org/ so I no longer need keepass2. It's better, and solves many problems including this one. I'd recommend it for everyone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.