From nobody@FreeBSD.org  Wed Feb 26 14:31:14 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 5B753A09
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 26 Feb 2014 14:31:14 +0000 (UTC)
Received: from newred.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 46D721FC0
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 26 Feb 2014 14:31:14 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by newred.freebsd.org (8.14.7/8.14.7) with ESMTP id s1QEVDnY042575
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 26 Feb 2014 14:31:13 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.7/8.14.7/Submit) id s1QEVDxK042543;
	Wed, 26 Feb 2014 14:31:13 GMT
	(envelope-from nobody)
Message-Id: <201402261431.s1QEVDxK042543@cgiserv.freebsd.org>
Date: Wed, 26 Feb 2014 14:31:13 GMT
From: Shayan Pooya <shayan@liveve.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Sort cannot be used for binary data.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         187083
>Category:       bin
>Synopsis:       [patch] sort(1) cannot be used for binary data.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 26 14:40:01 UTC 2014
>Closed-Date:    
>Last-Modified:  Wed Apr 16 02:21:43 UTC 2014
>Originator:     Shayan Pooya
>Release:        10.0
>Organization:
Chango
>Environment:
The problem is independent of the OS version and can be reproduced on all public versions.
>Description:
Sort has an unnecessary check that prevents it from being used for binary data:
https://github.com/freebsd/freebsd/blob/master/usr.bin/sort/sort.c#L1063


Here is the mailing list discussion (not very useful):
http://freebsd.1045724.n5.nabble.com/Field-delimiter-in-sort-program-in-freebsd-td5879776.html
>How-To-Repeat:
$ sort -t $'\xff'

complains about the delimiter.
>Fix:
Just remove the bogus condition:


diff --git a/sort.c b/sort.c
index d811a86..664b214 100644
--- a/sort.c
+++ b/sort.c
@@ -1060,10 +1060,6 @@ main(int argc, char **argv)
}
sort_opts_vals.tflag = true;
sort_opts_vals.field_sep = btowc(optarg[0]);
- if (sort_opts_vals.field_sep == WEOF) {
- errno = EINVAL;
- err(2, NULL);
- }
if (!gnusort_numeric_compatibility) {
if (symbol_decimal_point == sort_opts_vals.field_sep)
symbol_decimal_point = WEOF;

>Release-Note:
>Audit-Trail:
>Unformatted:
