From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Nov 18 09:30:10 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A258B106566B for ; Fri, 18 Nov 2011 09:30:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7E3AF8FC17 for ; Fri, 18 Nov 2011 09:30:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id pAI9UAbS000412 for ; Fri, 18 Nov 2011 09:30:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id pAI9UA1p000410; Fri, 18 Nov 2011 09:30:10 GMT (envelope-from gnats) Resent-Date: Fri, 18 Nov 2011 09:30:10 GMT Resent-Message-Id: <201111180930.pAI9UA1p000410@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Valentin Davydov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64ECA106566B for ; Fri, 18 Nov 2011 09:29:01 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 3ACF28FC13 for ; Fri, 18 Nov 2011 09:29:01 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pAI9T00G074978 for ; Fri, 18 Nov 2011 09:29:00 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id pAI9T0mA074977; Fri, 18 Nov 2011 09:29:00 GMT (envelope-from nobody) Message-Id: <201111180929.pAI9T0mA074977@red.freebsd.org> Date: Fri, 18 Nov 2011 09:29:00 GMT From: Valentin Davydov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/162650: sqlite3 command shell incorrectly handles some blobs X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2011 09:30:10 -0000 >Number: 162650 >Category: ports >Synopsis: sqlite3 command shell incorrectly handles some blobs >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Nov 18 09:30:10 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Valentin Davydov >Release: RELENG_8_2 >Organization: State Optical Institute >Environment: FreeBSD hostname.domain 8.2-STABLE FreeBSD 8.2-STABLE #13: Fri Apr 29 12:54:43 MSD 2011 user@hostname.domain:/usr/obj/usr/src/sys/KOR i386 >Description: When the commadline shell supplied with databases/sqlite3 (any version of year 2010 and later) is asked to output database content in the form of SQL statement (by issuing .mode insert), and actual data contains blobs, some of them gets corrupted in the output. This is due to the datatype/format mismatch in one of the internal functions of the shell called output_hex_blob(). >How-To-Repeat: Take FreeBSD 8.x (bug was tested on several various versions, both i386 and amd64). Install port databases/sqlite3, either compiling from ports or through binary package. Then launch sqlite3 shell and give it commands as shown below (shell responses are indented for clarity): $ sqlite3 db.tmp SQLite version 3.7.9 2011-11-01 00:52:41 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t(v blob); sqlite> insert into t values(X'0123456789'); sqlite> .mode insert sqlite> select * from t; INSERT INTO table VALUES(X'01234567ffffff89'); >Fix: Following patch helps (save it as databases/sqlite3/files/patch-src-shell.c) --- src/shell.c.orig 2011-11-01 16:31:18.000000000 +0400 +++ src/shell.c 2011-11-10 22:45:11.000000000 +0400 @@ -490,7 +490,7 @@ */ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){ int i; - char *zBlob = (char *)pBlob; + unsigned char *zBlob = (unsigned char *)pBlob; fprintf(out,"X'"); for(i=0; iRelease-Note: >Audit-Trail: >Unformatted: