From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17521 invoked by alias); 29 Jun 2012 09:47:52 -0000 Received: (qmail 17507 invoked by uid 22791); 29 Jun 2012 09:47:50 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from ns2.sietec.de (HELO mail.sietec.de) (213.61.69.205) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jun 2012 09:47:35 +0000 Received: from mail.bln1.bf.nsn-intra.net (ns2.bln1.bf.nsn-intra.net [10.149.159.159]) by mail.sietec.de (8.13.5/8.13.5/MTA) with ESMTP id q5T9lNdw021585 for ; Fri, 29 Jun 2012 11:47:31 +0200 (MEST) Received: from [10.149.153.168] (stm11786.bln1.bf.nsn-intra.net [10.149.153.168]) by mail.bln1.bf.nsn-intra.net (8.13.5/8.13.5/MTA) with ESMTP id q5T9lMeH028475 for ; Fri, 29 Jun 2012 11:47:22 +0200 (CEST) Message-ID: <4FED79A6.6050401@towo.net> Date: Fri, 29 Jun 2012 09:47:00 -0000 From: Thomas Wolff User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: /dev/clipboard corrupted References: <1286377403.634959.1340961856516.JavaMail.open-xchange@email.1und1.de> In-Reply-To: <1286377403.634959.1340961856516.JavaMail.open-xchange@email.1und1.de> Content-Type: multipart/mixed; boundary="------------070005060406010206040403" X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2012-06/txt/msg00558.txt.bz2 --------------070005060406010206040403 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1924 On 29.06.2012 11:24, Corinna Vinschen wrote: > On Jun 28 20:33, Thomas Wolff wrote: >> Am 28.06.2012 10:20, schrieb Corinna Vinschen: >>> On Jun 28 00:16, Thomas Wolff wrote: >>>> If the clipboard contains large data, the contents retrieved from >>>> /dev/clipboard gets corrupted. >>>> I compared the following in a few cases: >>>> * cat /dev/clipboard or cp /dev/clipboard (which are equal) >>>> * mouse-paste into mintty, read with cat >>>> * read /dev/clipboard within application >>>> >>>> and I found all three results to be different, the correct one >>>> sometimes being cat /dev/clipboard but not always. >>>> In today's case, the differences occured at byte 10240 and 65536 >>>> respectively, thus 10K-1 bytes or 64K-1 bytes being equal. >>> I can't reprocude this. There's also nothing in the /dev/clipboard >>> code which would rely on a 10K buffer or so. 64K, yes. But still, >>> I tried with wordpad, vi, mintty, cat, and cp with a text file of >>> about 90K. No problems. Do you have any reproducible testcase? >> Not really reproducible (maybe later) but some more observations. >> I made a small test program to read /dev/clipboard directly with >> different buffer sizes. > You know, we just love STCs. Send you small test program here, plus a > short instruction how you created the clipboard content and how to call > the testcase to see the problem. Sure, so here it is. Open clipboard.txt with notepad, ^A^C to copy all, then run the program to see bytes skipped. Actually it seems to skip as many bytes per read() as there were additional UTF-8 bytes (more bytes than characters) in the preceding read block. Checking the code again, variable pos seems to be used both as an index into the clipboard (WCHAR) and an offset to the resulting string length (char) which would explain the effect (not having checked all the details though as I'm not familiar with the used APIs). ------ Thomas --------------070005060406010206040403 Content-Type: text/plain; charset=UTF-8; name="clipboard.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="clipboard.txt" Content-length: 340 Scoloplos ist euryök. Er ist in der gesamten borealen Region in fast allen marinen Sedimenten zu finden, die einen sandigen Anteil aufweisen. Man findet ihn von Grönland bis zum Mittelmeer, in der Nordsee, an der kanadischen Küste und im Weißen Meer (Markelova 1981). Er besiedelt sowohl das «Eulitoral» als auch das „Bathyal“. --------------070005060406010206040403 Content-Type: text/plain; charset=windows-1252; name="rcb.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rcb.c" Content-length: 687 #include #include #include int main (int argc, char * * argv) { char * fn = "/dev/clipboard"; int fd = open (fn, O_RDONLY | O_BINARY, 0); if (fd < 0) { exit (fd); } int out_tty = isatty (1); int filebuflen = 100; argc --; if (argc > 0) { int ret = sscanf (argv [1], "%d", & filebuflen); } fprintf (stderr, "filebuflen %d\n", filebuflen); char * filebuf = malloc (filebuflen + 1); int n; do { n = read (fd, filebuf, filebuflen); if (out_tty) { filebuf [n] = 0; printf ("read %d bytes: <%s>\n", n, filebuf); } else { fprintf (stderr, "read %d bytes\n", n); write (1, filebuf, n); } } while (n > 0); close (fd); } --------------070005060406010206040403 Content-Type: text/plain; charset=us-ascii Content-length: 218 -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------070005060406010206040403--