CVS commit: src/dist/dhcp/dst
Module Name:src Committed By: christos Date: Thu Sep 22 12:38:34 UTC 2011 Modified Files: src/dist/dhcp/dst: prandom.c Log Message: check the result of malloc (Maksymilian Arciemowicz) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/dist/dhcp/dst/prandom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/dist/dhcp/dst/prandom.c diff -u src/dist/dhcp/dst/prandom.c:1.6 src/dist/dhcp/dst/prandom.c:1.7 --- src/dist/dhcp/dst/prandom.c:1.6 Tue Jan 26 14:11:00 2010 +++ src/dist/dhcp/dst/prandom.c Thu Sep 22 08:38:33 2011 @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/prandom.c,v 1.6 2010/01/26 19:11:00 drochner Exp $; +static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/prandom.c,v 1.7 2011/09/22 12:38:33 christos Exp $; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -26,6 +26,7 @@ #include fcntl.h #include time.h #include dirent.h +#include err.h #include sys/param.h #include sys/stat.h #include sys/time.h @@ -454,6 +455,8 @@ if (hash-step 1) { /* if using subset of input data */ tmp_size = size / hash-step + 2; abuf = tp = malloc(tmp_size); + if (tp == NULL) + err(1, malloc); tmp = tp; for (cnt = 0, i = hash-curr; i size; i += hash-step, cnt++) *(tp++) = input[i];
CVS commit: src/dist/dhcp/dst
Module Name:src Committed By: drochner Date: Tue Jan 26 19:11:01 UTC 2010 Modified Files: src/dist/dhcp/dst: dst_api.c dst_internal.h prandom.c Log Message: rather than adding braces in the code, define the offending macro to (void)0. This is what similar code in bind9 (up to 9.5) does. (native NetBSD code usually does do { } while (/* CONSTCOND */ 0) in this case) Anyway, I've checked the code, didn't find ambiguities due to the empty statements, so the whole thing is harmless. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/dist/dhcp/dst/dst_api.c cvs rdiff -u -r1.1 -r1.2 src/dist/dhcp/dst/dst_internal.h cvs rdiff -u -r1.5 -r1.6 src/dist/dhcp/dst/prandom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/dist/dhcp/dst/dst_api.c diff -u src/dist/dhcp/dst/dst_api.c:1.6 src/dist/dhcp/dst/dst_api.c:1.7 --- src/dist/dhcp/dst/dst_api.c:1.6 Mon Jan 25 20:33:57 2010 +++ src/dist/dhcp/dst/dst_api.c Tue Jan 26 19:11:00 2010 @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/dst_api.c,v 1.6 2010/01/25 20:33:57 drochner Exp $; +static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/dst_api.c,v 1.7 2010/01/26 19:11:00 drochner Exp $; #endif /* @@ -684,10 +684,9 @@ if (key_st-dk_func-from_dns_key(key_st, rdata[start], len - start) 0) return (key_st); - } else { + } else EREPORT((dst_dnskey_to_public_key(): unsuppored alg %d\n, alg)); - } SAFE_FREE(key_st); return (key_st); @@ -746,10 +745,9 @@ return (enc_len + loc); else return (-1); - } else { + } else EREPORT((dst_key_to_dnskey(): Unsupported ALG %d\n, key-dk_alg)); - } return (-1); } @@ -879,11 +877,10 @@ EREPORT((dst_s_read_private_key_file(): Unknown keyfile %d.%d version for %s\n, file_major, file_minor, name)); goto fail; - } else if (file_major major || file_minor minor) { + } else if (file_major major || file_minor minor) EREPORT(( dst_s_read_private_key_file(): Keyfile %s version higher than mine %d.%d MAY FAIL\n, name, file_major, file_minor)); - } while (*p++ != '\n') ; /* skip to end of line */ Index: src/dist/dhcp/dst/dst_internal.h diff -u src/dist/dhcp/dst/dst_internal.h:1.1 src/dist/dhcp/dst/dst_internal.h:1.2 --- src/dist/dhcp/dst/dst_internal.h:1.1 Fri Aug 3 11:35:34 2001 +++ src/dist/dhcp/dst/dst_internal.h Tue Jan 26 19:11:00 2010 @@ -60,7 +60,7 @@ #ifdef REPORT_ERRORS #define EREPORT(str) printf str #else -#define EREPORT(str) +#define EREPORT(str) (void)0 #endif /* use our own special macro to FRRE memory */ Index: src/dist/dhcp/dst/prandom.c diff -u src/dist/dhcp/dst/prandom.c:1.5 src/dist/dhcp/dst/prandom.c:1.6 --- src/dist/dhcp/dst/prandom.c:1.5 Mon Jan 25 20:33:57 2010 +++ src/dist/dhcp/dst/prandom.c Tue Jan 26 19:11:00 2010 @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/prandom.c,v 1.5 2010/01/25 20:33:57 drochner Exp $; +static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/prandom.c,v 1.6 2010/01/26 19:11:00 drochner Exp $; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -850,9 +850,8 @@ i = dst_sign_data(SIG_MODE_ALL, my_key, NULL, (u_char *) counter, hb_size, semi_old, sizeof(semi_old)); - if (i != hb_size) { + if (i != hb_size) EREPORT((HMAC SIGNATURE FAILURE %d\n, i)); - } cnt++; if (size - out i) /* Not all data is needed */ semi_loc = i = size - out;
CVS commit: src/dist/dhcp/dst
Module Name:src Committed By: drochner Date: Mon Jan 25 20:33:57 UTC 2010 Modified Files: src/dist/dhcp/dst: dst_api.c prandom.c Log Message: fix some cases where the EREPORT macro defined to null (as in the NetBSD build) could change the behaviour of the code in unexpected ways To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/dist/dhcp/dst/dst_api.c cvs rdiff -u -r1.4 -r1.5 src/dist/dhcp/dst/prandom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/dist/dhcp/dst/dst_api.c diff -u src/dist/dhcp/dst/dst_api.c:1.5 src/dist/dhcp/dst/dst_api.c:1.6 --- src/dist/dhcp/dst/dst_api.c:1.5 Thu Aug 11 17:13:21 2005 +++ src/dist/dhcp/dst/dst_api.c Mon Jan 25 20:33:57 2010 @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/dst_api.c,v 1.5 2005/08/11 17:13:21 drochner Exp $; +static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/dst_api.c,v 1.6 2010/01/25 20:33:57 drochner Exp $; #endif /* @@ -684,9 +684,10 @@ if (key_st-dk_func-from_dns_key(key_st, rdata[start], len - start) 0) return (key_st); - } else + } else { EREPORT((dst_dnskey_to_public_key(): unsuppored alg %d\n, alg)); + } SAFE_FREE(key_st); return (key_st); @@ -745,9 +746,10 @@ return (enc_len + loc); else return (-1); - } else + } else { EREPORT((dst_key_to_dnskey(): Unsupported ALG %d\n, key-dk_alg)); + } return (-1); } @@ -877,10 +879,11 @@ EREPORT((dst_s_read_private_key_file(): Unknown keyfile %d.%d version for %s\n, file_major, file_minor, name)); goto fail; - } else if (file_major major || file_minor minor) + } else if (file_major major || file_minor minor) { EREPORT(( dst_s_read_private_key_file(): Keyfile %s version higher than mine %d.%d MAY FAIL\n, name, file_major, file_minor)); + } while (*p++ != '\n') ; /* skip to end of line */ Index: src/dist/dhcp/dst/prandom.c diff -u src/dist/dhcp/dst/prandom.c:1.4 src/dist/dhcp/dst/prandom.c:1.5 --- src/dist/dhcp/dst/prandom.c:1.4 Thu Aug 11 17:13:21 2005 +++ src/dist/dhcp/dst/prandom.c Mon Jan 25 20:33:57 2010 @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/prandom.c,v 1.4 2005/08/11 17:13:21 drochner Exp $; +static const char rcsid[] = $Header: /cvsroot/src/dist/dhcp/dst/prandom.c,v 1.5 2010/01/25 20:33:57 drochner Exp $; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -850,8 +850,9 @@ i = dst_sign_data(SIG_MODE_ALL, my_key, NULL, (u_char *) counter, hb_size, semi_old, sizeof(semi_old)); - if (i != hb_size) + if (i != hb_size) { EREPORT((HMAC SIGNATURE FAILURE %d\n, i)); + } cnt++; if (size - out i) /* Not all data is needed */ semi_loc = i = size - out;