From owner-p4-projects@FreeBSD.ORG Thu Mar 12 20:54:53 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D98F61065675; Thu, 12 Mar 2009 20:54:52 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DA4C106566C for ; Thu, 12 Mar 2009 20:54:52 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6B7588FC28 for ; Thu, 12 Mar 2009 20:54:52 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n2CKsqO1062930 for ; Thu, 12 Mar 2009 20:54:52 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n2CKsqFR062928 for perforce@freebsd.org; Thu, 12 Mar 2009 20:54:52 GMT (envelope-from gabor@freebsd.org) Date: Thu, 12 Mar 2009 20:54:52 GMT Message-Id: <200903122054.n2CKsqFR062928@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 159137 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2009 20:54:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=159137 Change 159137 by gabor@gabor_server on 2009/03/12 20:54:10 - Stricter checking after stroull() - Use libc messages through errno where possible Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#84 edit .. //depot/projects/soc2008/gabor_textproc/grep/nls/C.msg#8 edit .. //depot/projects/soc2008/gabor_textproc/grep/nls/es_ES.ISO8859-1.msg#1 add .. //depot/projects/soc2008/gabor_textproc/grep/nls/hu_HU.ISO8859-2.msg#7 edit .. //depot/projects/soc2008/gabor_textproc/grep/nls/pt_BR.ISO8859-1.msg#7 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#84 (text+ko) ==== @@ -70,11 +70,9 @@ /* 5*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n", /* 6*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n", /* 7*/ "\t[--null] [pattern] [file ...]\n", -/* 8*/ "value out of range", -/* 9*/ "context out of range", +/* 8*/ "unknown --binary-files option", +/* 9*/ "Binary file %s matches\n" /*10*/ "%s (BSD grep) %s\n", -/*11*/ "unknown --binary-files option", -/*12*/ "Binary file %s matches\n" }; /* Flags passed to regcomp() and regexec() */ @@ -375,8 +373,10 @@ case '5': case '6': case '7': case '8': case '9': if (newarg || !isdigit(lastc)) Aflag = 0; - else if (Aflag > LLONG_MAX / 10) - errx(2, getstr(9)); + else if (Aflag > LLONG_MAX / 10) { + errno = ERANGE; + err(2, NULL); + } Aflag = Bflag = (Aflag * 10) + (c - '0'); break; case 'C': @@ -388,8 +388,13 @@ case 'A': case 'B': l = strtoull(optarg, &ep, 10); - if ((errno == ERANGE) && (l == ULLONG_MAX)) - errx(2, getstr(9)); + if (((errno == ERANGE) && (l == ULLONG_MAX)) || + ((errno == EINVAL) && (l == 0))) + err(2, NULL); + else if (ep[0] != '\0') { + errno = EINVAL; + err(2, NULL); + } if (c == 'A') Aflag = l; else if (c == 'B') @@ -416,8 +421,10 @@ dirbehave = DIR_RECURSE; } else if (strcmp("skip", optarg) == 0) dirbehave = DIR_SKIP; - else if (strcmp("read", optarg) != 0) - errx(2, getstr(8)); + else if (strcmp("read", optarg) != 0) { + errno = EINVAL; + err(2, NULL); + } break; case 'E': grepbehave = GREP_EXTENDED; @@ -464,9 +471,14 @@ break; case 'm': mflag++; - mcount = strtoull(optarg, (char **)NULL, 10); - if ((errno == ERANGE) && (mcount == ULLONG_MAX)) - err(2, getstr(8)); + mcount = strtoull(optarg, &ep, 10); + if (((errno == ERANGE) && (mcount == ULLONG_MAX)) || + ((errno == EINVAL) && (mcount == 0))) + err(2, NULL); + else if (ep[0] != '\0') { + errno = EINVAL; + err(2, NULL); + } break; case 'n': nflag = 1; ==== //depot/projects/soc2008/gabor_textproc/grep/nls/C.msg#8 (text+ko) ==== @@ -9,8 +9,6 @@ 5 "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n" 6 "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n" 7 "\t[--null] [pattern] [file ...]\n" -8 "value out of range" -9 "context out of range" +8 "unknown --binary-files option" +9 "Binary file %s matches\n" 10 "%s (BSD grep) %s\n" -11 "unknown --binary-files option" -12 "Binary file %s matches\n" ==== //depot/projects/soc2008/gabor_textproc/grep/nls/hu_HU.ISO8859-2.msg#7 (text+ko) ==== @@ -9,8 +9,6 @@ 5 "\t[-e minta] [-f fájl] [--binary-files=érték] [--color=mikor]\n" 6 "\t[--context[=szám]] [--directories=művelet] [--label] [--line-buffered]\n" 7 "\t[--null] [minta] [fájl ...]\n" -8 "az érték a megengedett tartományon kívül esik" -9 "a kontextus a megengedett tartományon kívül esik" +8 "ismeretlen --binary-files opció" +9 "%s bináris fájl illeszkedik\n" 10 "%s (BSD grep) %s\n" -11 "ismeretlen --binary-files opció" -12 "%s bináris fájl illeszkedik\n" ==== //depot/projects/soc2008/gabor_textproc/grep/nls/pt_BR.ISO8859-1.msg#7 (text+ko) ==== @@ -9,8 +9,6 @@ 5 "\t[-e padrăo] [-f arquivo] [--binary-files=valor] [--color=quando]\n" 6 "\t[--context[=num]] [--directories=açăo] [--label] [--line-buffered]\n" 7 "\t[--null] [padrăo] [arquivo ...]\n" -8 "el valor está fora da escala" -9 "contexto está fora da escala" +8 "opcăo năo conhecida de --binary-files" +9 "arquivo binário %s casa com o padrăo\n" 10 "%s (BSD grep) %s\n" -11 "opcăo năo conhecida de --binary-files" -12 "arquivo binário %s casa com o padrăo\n"