CVS commit: othersrc/external/bsd/rs/dist
Module Name:othersrc Committed By: agc Date: Tue Dec 4 07:24:19 UTC 2012 Modified Files: othersrc/external/bsd/rs/dist: rs.c Log Message: feedback from fuzz testing - check arguments to functions on input. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/rs/dist/rs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/rs/dist/rs.c diff -u othersrc/external/bsd/rs/dist/rs.c:1.3 othersrc/external/bsd/rs/dist/rs.c:1.4 --- othersrc/external/bsd/rs/dist/rs.c:1.3 Tue Apr 26 15:41:26 2011 +++ othersrc/external/bsd/rs/dist/rs.c Tue Dec 4 07:24:19 2012 @@ -513,6 +513,9 @@ le32(uint32_t in) int rs_init(rs_t *rs, const unsigned poly, const uint8_t databytes, const uint8_t paritybytes) { + if (rs == NULL) { + return 0; + } if (paritybytes databytes) { (void) fprintf(stderr, paritybytes %u larger than data bytes %u\n, paritybytes, databytes); @@ -544,6 +547,9 @@ rs_encode(rs_t *rs, const void *inp, siz size_t incc; size_t chunk; + if (rs == NULL || inp == NULL || out == NULL) { + return -1; + } if (!rs-header.poly) { rs_init(rs, RS_DEFAULT_POLYNOMIAL, RS_DEFAULT_DATA, RS_DEFAULT_PARITY); } @@ -564,6 +570,9 @@ rs_decode(rs_t *rs, const void *inp, siz size_t incc; size_t chunk; + if (rs == NULL || inp == NULL || out == NULL) { + return -1; + } for (outcc = 0, incc = 0 ; incc size outcc (ssize_t)outsize ; incc += chunk) { chunk = MIN(size - incc, rs-header.datac + rs-header.parityc); if ((cc = decode_chunk(rs, in[incc], chunk, out[outcc])) 0) { @@ -580,6 +589,9 @@ rs_get_header(rs_t *rs, const void *in, { rs_header_t head; + if (rs == NULL || in == NULL) { + return -1; + } USE_ARG(insize); (void) memcpy(head, in, sizeof(head)); head.poly = le32(head.poly); @@ -593,6 +605,9 @@ rs_put_header(rs_t *rs, void *out, size_ { rs_header_t head; + if (rs == NULL || out == NULL) { + return -1; + } USE_ARG(outsize); (void) memcpy(head, rs-header, sizeof(head)); (void) snprintf(head.magic, sizeof(head.magic), %s, RS_MAGIC); @@ -611,6 +626,9 @@ rs_parity(rs_t *rs, const void *inp, siz size_t incc; size_t chunk; + if (rs == NULL || inp == NULL || out == NULL) { + return -1; + } if (!rs-header.poly) { rs_init(rs, RS_DEFAULT_POLYNOMIAL, RS_DEFAULT_DATA, RS_DEFAULT_PARITY); }
CVS commit: othersrc/external/bsd/rs/dist
Module Name:othersrc Committed By: agc Date: Fri Mar 18 23:43:13 UTC 2011 Modified Files: othersrc/external/bsd/rs/dist: main.c Log Message: get rid of debugging comment To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/rs/dist/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/rs/dist/main.c diff -u othersrc/external/bsd/rs/dist/main.c:1.2 othersrc/external/bsd/rs/dist/main.c:1.3 --- othersrc/external/bsd/rs/dist/main.c:1.2 Thu Mar 17 03:21:11 2011 +++ othersrc/external/bsd/rs/dist/main.c Fri Mar 18 23:43:13 2011 @@ -140,8 +140,6 @@ } (void) memset(rs, 0x0, sizeof(rs)); /* Initialization of the ECC library */ -/* databytes: def 224, should be 255 */ -/* parity: def 32, should be 223 */ if (!rs_init(rs, poly, databytes, parity)) { exit(EXIT_FAILURE); }
CVS commit: othersrc/external/bsd/rs/dist
Module Name:othersrc Committed By: agc Date: Fri Mar 18 23:59:55 UTC 2011 Modified Files: othersrc/external/bsd/rs/dist: main.c Log Message: check for the appropriate terminating character To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/rs/dist/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/rs/dist/main.c diff -u othersrc/external/bsd/rs/dist/main.c:1.3 othersrc/external/bsd/rs/dist/main.c:1.4 --- othersrc/external/bsd/rs/dist/main.c:1.3 Fri Mar 18 23:43:13 2011 +++ othersrc/external/bsd/rs/dist/main.c Fri Mar 18 23:59:55 2011 @@ -119,7 +119,7 @@ break; case 'b': case 'p': - for (s = optarg, data2 = 0 ; *s *s != '/' ; s++) { + for (s = optarg, data2 = 0 ; *s *s != ',' ; s++) { data2 = (data2 * 10) + (*s - '0'); } if (*s == ',') {
CVS commit: othersrc/external/bsd/rs/dist
Module Name:othersrc Committed By: agc Date: Thu Mar 17 03:21:11 UTC 2011 Modified Files: othersrc/external/bsd/rs/dist: main.c rs.1 Log Message: rework the data/parity bytes command line specification to be more natural, especially for this area of erasure codes. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/rs/dist/main.c cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/rs/dist/rs.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/rs/dist/main.c diff -u othersrc/external/bsd/rs/dist/main.c:1.1.1.1 othersrc/external/bsd/rs/dist/main.c:1.2 --- othersrc/external/bsd/rs/dist/main.c:1.1.1.1 Sat Mar 12 08:08:29 2011 +++ othersrc/external/bsd/rs/dist/main.c Thu Mar 17 03:21:11 2011 @@ -93,8 +93,11 @@ unsigned poly; uint8_t databytes; uint8_t parity; + uint8_t data2; + uint8_t par2; rs_t rs; char *out; + char *s; int encoding; int i; @@ -108,17 +111,24 @@ case 'P': poly = (unsigned)strtol(optarg, NULL, 16); break; - case 'b': - databytes = atoi(optarg) 0xff; - break; case 'd': encoding = 0; break; case 'o': out = optarg; break; + case 'b': case 'p': - parity = atoi(optarg) 0xff; + for (s = optarg, data2 = 0 ; *s *s != '/' ; s++) { +data2 = (data2 * 10) + (*s - '0'); + } + if (*s == ',') { +for (s++, par2 = 0 ; *s ; s++) { + par2 = (par2 * 10) + (*s - '0'); +} +parity = data2 - par2; +databytes = par2; + } break; case 'v': printf(Version: %u\n, PKG_VERSION); @@ -130,6 +140,8 @@ } (void) memset(rs, 0x0, sizeof(rs)); /* Initialization of the ECC library */ +/* databytes: def 224, should be 255 */ +/* parity: def 32, should be 223 */ if (!rs_init(rs, poly, databytes, parity)) { exit(EXIT_FAILURE); } Index: othersrc/external/bsd/rs/dist/rs.1 diff -u othersrc/external/bsd/rs/dist/rs.1:1.2 othersrc/external/bsd/rs/dist/rs.1:1.3 --- othersrc/external/bsd/rs/dist/rs.1:1.2 Sat Mar 12 13:20:00 2011 +++ othersrc/external/bsd/rs/dist/rs.1 Thu Mar 17 03:21:11 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: rs.1,v 1.2 2011/03/12 13:20:00 wiz Exp $ +.\ $NetBSD: rs.1,v 1.3 2011/03/17 03:21:11 agc Exp $ .\ .\ Copyright (c) 2011 Alistair Crooks a...@netbsd.org .\ All rights reserved. @@ -23,7 +23,7 @@ .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\ -.Dd March 10, 2011 +.Dd March 16, 2011 .Dt RS 1 .Os .Sh NAME @@ -32,9 +32,9 @@ .Sh SYNOPSIS .Nm .Fl dv -.Op Fl b Ar data-bytes +.Op Fl b Ar total-bytes,parity-bytes .Op Fl o Ar filename -.Op Fl p Ar parity-bytes +.Op Fl p Ar total-bytes,parity-bytes .Ar file ... .Sh DESCRIPTION The @@ -60,32 +60,26 @@ data bytes. .Pp The following options are available: -.Bl -tag -width parity-bytes-and +.Bl -tag -width total-bytes-and-data-bytes .It Fl d decode the file(s) given, or .Dv stdin if no files were specified. -.It Fl v -print the version information on -.Dv stdout -and then exit. -.It Fl b Ar data-bytes -specifies the number of data bytes to be used in an output packet. +.It Fl b Ar total-bytes,data-bytes +.It Fl p Ar total-bytes,data-bytes +specifies the total number of bytes in an +.Dq output packet +as well as the number of data bytes to be used in an output packet. If no value is specified, -.Dv 224 +.Dv 255,223 is used. +This will protect against 16 errors in the data. .It Fl o Ar output-file use the specified file for output. By default, output will go to .Dv stdout -.It Fl p Ar parity-bytes -specifies the number of parity bytes to be used in an output packet. -If no value is specified, -.Dv 32 -is used. -This will protect against 16 errors in the data. .It Fl v -prints the version of +prints the version information of .Nm on .Dv stdout
CVS commit: othersrc/external/bsd/rs/dist
Module Name:othersrc Committed By: wiz Date: Sat Mar 12 13:20:00 UTC 2011 Modified Files: othersrc/external/bsd/rs/dist: rs.1 Log Message: Sort sections, remove superfluous Pp, upper-case names. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/rs/dist/rs.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/rs/dist/rs.1 diff -u othersrc/external/bsd/rs/dist/rs.1:1.1.1.1 othersrc/external/bsd/rs/dist/rs.1:1.2 --- othersrc/external/bsd/rs/dist/rs.1:1.1.1.1 Sat Mar 12 08:08:29 2011 +++ othersrc/external/bsd/rs/dist/rs.1 Sat Mar 12 13:20:00 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: rs.1,v 1.1.1.1 2011/03/12 08:08:29 agc Exp $ +.\ $NetBSD: rs.1,v 1.2 2011/03/12 13:20:00 wiz Exp $ .\ .\ Copyright (c) 2011 Alistair Crooks a...@netbsd.org .\ All rights reserved. @@ -28,7 +28,7 @@ .Os .Sh NAME .Nm rs -.Nd reed-solomon erasure coding +.Nd Reed-Solomon erasure coding .Sh SYNOPSIS .Nm .Fl dv @@ -91,8 +91,12 @@ .Dv stdout and exits. .El -.Pp -.Sh EXAMPLE +.Sh RETURN VALUES +The +.Nm +utility will return 0 for success, +and 1 for failure. +.Sh EXAMPLES .Bd -literal % cp Makefile a % rs -o a.rs a @@ -106,11 +110,6 @@ % cmp a a.2 % .Ed -.Sh RETURN VALUES -The -.Nm -utility will return 0 for success, -and 1 for failure. .Sh SEE ALSO .Xr librs 3 .Sh HISTORY