To: vim-dev@vim.org Subject: Patch 6.1a.001 (extra) Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1a.001 (extra) Problem: 32bit DOS: copying text to the clipboard may cause a crash. (Jonathan D Johnston) Solution: Don't copy one byte too much in SetClipboardData(). Files: src/os_msdos.c *** ../vim61a.000/src/os_msdos.c Sun Feb 17 17:16:02 2002 --- src/os_msdos.c Mon Feb 25 21:06:26 2002 *************** *** 1432,1438 **** clip_init(FALSE); /* no clipboard available, too bad */ else /* else, running under Windows, OK */ clip_init(TRUE); /* clipboard is available */ - #endif } --- 1432,1437 ---- *************** *** 2938,2943 **** --- 2937,2943 ---- int real_mode_segment_address; int protected_mode_selector; long_u protected_mode_offset = 0L; + int total_size = clip_data_size; char_u *clip_sel_type; *************** *** 2946,2952 **** * of text selection: MLINE, MCHAR, or MBLOCK. */ if (clip_data_format == CF_VIMCLIP) ! clip_data_size++; /* extra byte for marker */ /* Data cannot be sent directly from a Vim string (pClipData) to * the Windows clipboard, because the Windows clipboard interface --- 2946,2952 ---- * of text selection: MLINE, MCHAR, or MBLOCK. */ if (clip_data_format == CF_VIMCLIP) ! total_size++; /* extra byte for marker */ /* Data cannot be sent directly from a Vim string (pClipData) to * the Windows clipboard, because the Windows clipboard interface *************** *** 2963,2969 **** * we can do about this, we simply have to fail. */ real_mode_segment_address = __dpmi_allocate_dos_memory( ! (clip_data_size + 15) >> 4, /* buffer size, in 16-byte paragraphs */ &protected_mode_selector); /* prot-mode selector for the address */ if (real_mode_segment_address == -1) --- 2963,2969 ---- * we can do about this, we simply have to fail. */ real_mode_segment_address = __dpmi_allocate_dos_memory( ! (total_size + 15) >> 4, /* buffer size, in 16-byte paragraphs */ &protected_mode_selector); /* prot-mode selector for the address */ if (real_mode_segment_address == -1) *************** *** 2980,2987 **** /* Copy data from Vim's buffer (clip_data) into the DOS transfer buffer. * This can be larger than 64K; movedata() takes care of crossing any ! * 16-bit segment boundaries. Note that clip_data_size's null terminator ! * is copied. * * If we're using Vim's custom clipboard format, we must copy one extra * byte to indicate the type of selection: line, character, or block. --- 2980,2986 ---- /* Copy data from Vim's buffer (clip_data) into the DOS transfer buffer. * This can be larger than 64K; movedata() takes care of crossing any ! * 16-bit segment boundaries. * * If we're using Vim's custom clipboard format, we must copy one extra * byte to indicate the type of selection: line, character, or block. *************** *** 3002,3008 **** _my_ds(), (unsigned)clip_sel_type, /* source: normal memory address */ protected_mode_selector, 0, /* target: DOS ad (via selector) */ ! STRLEN(clip_sel_type)); /* how many bytes to copy */ protected_mode_offset += STRLEN(clip_sel_type); /* allow for marker */ } --- 3001,3007 ---- _my_ds(), (unsigned)clip_sel_type, /* source: normal memory address */ protected_mode_selector, 0, /* target: DOS ad (via selector) */ ! 1); /* how many bytes to copy */ protected_mode_offset += STRLEN(clip_sel_type); /* allow for marker */ } *************** *** 3019,3031 **** */ dpmi_regs.x.ax = 0x1703; /* send clipboard data */ dpmi_regs.x.dx = clip_data_format; /* flag: format of the data */ ! dpmi_regs.x.si = ((clip_data_size >> 16) & 0x0000ffffL); /* hi word of data size */ ! dpmi_regs.x.cx = (clip_data_size & 0x0000ffffL); /* lo word of data size */ dpmi_regs.x.es = real_mode_segment_address; /* buffer address: segment */ dpmi_regs.x.bx = 0; /* buffer address: offset */ ! if (__dpmi_int( 0x2f, &dpmi_regs) == -1) { /* real-mode interrupt failed. */ FreeDOSMemory(protected_mode_selector); /* clean up DOS memory */ --- 3018,3030 ---- */ dpmi_regs.x.ax = 0x1703; /* send clipboard data */ dpmi_regs.x.dx = clip_data_format; /* flag: format of the data */ ! dpmi_regs.x.si = ((total_size >> 16) & 0x0000ffffL); /* hi word of data size */ ! dpmi_regs.x.cx = (total_size & 0x0000ffffL); /* lo word of data size */ dpmi_regs.x.es = real_mode_segment_address; /* buffer address: segment */ dpmi_regs.x.bx = 0; /* buffer address: offset */ ! if (__dpmi_int(0x2f, &dpmi_regs) == -1) { /* real-mode interrupt failed. */ FreeDOSMemory(protected_mode_selector); /* clean up DOS memory */ *** ../vim61a.000/src/version.c Sun Feb 24 17:18:28 2002 --- src/version.c Mon Feb 25 21:09:18 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 1, /**/ -- This planet has -- or rather had -- a problem, which was this: most of the people living on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movements of small green pieces of paper, which is odd because on the whole it wasn't the small green pieces of paper that were unhappy. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///