Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Unified Diff: src/platform/vboot_reference/utils/dumpRSAPublicKey.c

Issue 861003: Check return value on write() to fix warning. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/vboot_reference/utils/dumpRSAPublicKey.c
diff --git a/src/platform/vboot_reference/utils/dumpRSAPublicKey.c b/src/platform/vboot_reference/utils/dumpRSAPublicKey.c
index 232fe9969a6bdeb16889a1ac854baea45b79793e..e3ac4b775473a0da574c6fd83293fd484fdf9f80 100644
--- a/src/platform/vboot_reference/utils/dumpRSAPublicKey.c
+++ b/src/platform/vboot_reference/utils/dumpRSAPublicKey.c
@@ -53,7 +53,9 @@ void output(RSA* key) {
N = key->n;
/* Output size of RSA key in 32-bit words */
nwords = BN_num_bits(N) / 32;
- write(1, &nwords, sizeof(nwords));
+ if (-1 == write(1, &nwords, sizeof(nwords)))
+ goto failure;
+
/* Initialize BIGNUMs */
Big1 = BN_new();
@@ -81,7 +83,8 @@ void output(RSA* key) {
BN_mod_inverse(N0inv, N, B, bn_ctx);
BN_sub(N0inv, B, N0inv);
n0invout = BN_get_word(N0inv);
- write(1, &n0invout, sizeof(n0invout));
+ if (-1 == write(1, &n0invout, sizeof(n0invout)))
+ goto failure;
/* Calculate R = 2^(# of key bits) */
BN_set_word(NnumBits, BN_num_bits(N));
@@ -99,7 +102,8 @@ void output(RSA* key) {
BN_mod(n, N, B, bn_ctx); /* n = N mod B */
nout = BN_get_word(n);
- write(1, &nout, sizeof(nout));
+ if (-1 == write(1, &nout, sizeof(nout)))
+ goto failure;
BN_rshift(N, N, 32); /* N = N/B */
}
@@ -110,11 +114,13 @@ void output(RSA* key) {
BN_mod(rr, RR, B, bn_ctx); /* rr = RR mod B */
rrout = BN_get_word(rr);
- write(1, &rrout, sizeof(rrout));
+ if (-1 == write(1, &rrout, sizeof(rrout)))
+ goto failure;
BN_rshift(RR, RR, 32); /* RR = RR/B */
}
+failure:
/* Free BIGNUMs. */
BN_free(Big1);
BN_free(Big2);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698