diff options
author | Khem Raj <raj.khem@gmail.com> | 2018-03-23 06:34:45 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-03-30 00:31:18 +0100 |
commit | 9280c476625ca3ee3301a115936f91d564767b80 (patch) | |
tree | 8c9f10d0361fb40290ee58e1af8ba52b4d5e9516 /meta/recipes-support/nss | |
parent | b9a1af507b843c173298cea85229e195eef3cd15 (diff) | |
download | poky-9280c476625ca3ee3301a115936f91d564767b80.tar.gz |
nss: Use snprintf in sign.c
Fies security warnings
| sign.c:86:31: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
| sprintf(fullfn, "%s/%s", tree, tempfn);
(From OE-Core rev: 7171e96f3a5f54c63674cf5282aea31bcb9cd7f9)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-support/nss')
-rw-r--r-- | meta/recipes-support/nss/nss/0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch | 119 | ||||
-rw-r--r-- | meta/recipes-support/nss/nss_3.35.bb | 1 |
2 files changed, 120 insertions, 0 deletions
diff --git a/meta/recipes-support/nss/nss/0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch b/meta/recipes-support/nss/nss/0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch new file mode 100644 index 0000000000..bc10f3385d --- /dev/null +++ b/meta/recipes-support/nss/nss/0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch | |||
@@ -0,0 +1,119 @@ | |||
1 | From 6f7d7be9997ba6727a5ad7c3800df9051160dc12 Mon Sep 17 00:00:00 2001 | ||
2 | From: Martin Thomson <martin.thomson@gmail.com> | ||
3 | Date: Tue, 13 Feb 2018 12:30:58 +1100 | ||
4 | Subject: [PATCH] Bug 1437734 - Use snprintf in sign.c, r=ttaubert | ||
5 | |||
6 | --HG-- | ||
7 | extra : rebase_source : 97921ece71ff86b18d32b891591608290eed4d83 | ||
8 | --- | ||
9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
10 | Upstream-Status: Backport [https://github.com/nss-dev/nss/commit/0a9078b3cde97add7c825c9d13467a8401ad0c88#diff-b42512151dc137537091f823f7701804.patch] | ||
11 | |||
12 | nss/cmd/signtool/sign.c | 58 ++++++++++++++++++++++++++++++++++++++++--------- | ||
13 | 1 file changed, 48 insertions(+), 10 deletions(-) | ||
14 | |||
15 | diff --git a/nss/cmd/signtool/sign.c b/nss/cmd/signtool/sign.c | ||
16 | index 6e776069a..6f8e43946 100644 | ||
17 | --- a/nss/cmd/signtool/sign.c | ||
18 | +++ b/nss/cmd/signtool/sign.c | ||
19 | @@ -43,6 +43,7 @@ SignArchive(char *tree, char *keyName, char *zip_file, int javascript, | ||
20 | int status; | ||
21 | char tempfn[FNSIZE], fullfn[FNSIZE]; | ||
22 | int keyType = rsaKey; | ||
23 | + int count; | ||
24 | |||
25 | metafile = meta_file; | ||
26 | optimize = _optimize; | ||
27 | @@ -81,9 +82,18 @@ SignArchive(char *tree, char *keyName, char *zip_file, int javascript, | ||
28 | } | ||
29 | |||
30 | /* rsa/dsa to zip */ | ||
31 | - sprintf(tempfn, "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa" | ||
32 | - : "rsa")); | ||
33 | - sprintf(fullfn, "%s/%s", tree, tempfn); | ||
34 | + count = snprintf(tempfn, sizeof(tempfn), "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa" : "rsa")); | ||
35 | + if (count >= sizeof(tempfn)) { | ||
36 | + PR_fprintf(errorFD, "unable to write key metadata\n"); | ||
37 | + errorCount++; | ||
38 | + exit(ERRX); | ||
39 | + } | ||
40 | + count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn); | ||
41 | + if (count >= sizeof(fullfn)) { | ||
42 | + PR_fprintf(errorFD, "unable to write key metadata\n"); | ||
43 | + errorCount++; | ||
44 | + exit(ERRX); | ||
45 | + } | ||
46 | JzipAdd(fullfn, tempfn, zipfile, compression_level); | ||
47 | |||
48 | /* Loop through all files & subdirectories, add to archive */ | ||
49 | @@ -93,20 +103,44 @@ SignArchive(char *tree, char *keyName, char *zip_file, int javascript, | ||
50 | } | ||
51 | /* mf to zip */ | ||
52 | strcpy(tempfn, "META-INF/manifest.mf"); | ||
53 | - sprintf(fullfn, "%s/%s", tree, tempfn); | ||
54 | + count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn); | ||
55 | + if (count >= sizeof(fullfn)) { | ||
56 | + PR_fprintf(errorFD, "unable to write manifest\n"); | ||
57 | + errorCount++; | ||
58 | + exit(ERRX); | ||
59 | + } | ||
60 | JzipAdd(fullfn, tempfn, zipfile, compression_level); | ||
61 | |||
62 | /* sf to zip */ | ||
63 | - sprintf(tempfn, "META-INF/%s.sf", base); | ||
64 | - sprintf(fullfn, "%s/%s", tree, tempfn); | ||
65 | + count = snprintf(tempfn, sizeof(tempfn), "META-INF/%s.sf", base); | ||
66 | + if (count >= sizeof(tempfn)) { | ||
67 | + PR_fprintf(errorFD, "unable to write sf metadata\n"); | ||
68 | + errorCount++; | ||
69 | + exit(ERRX); | ||
70 | + } | ||
71 | + count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn); | ||
72 | + if (count >= sizeof(fullfn)) { | ||
73 | + PR_fprintf(errorFD, "unable to write sf metadata\n"); | ||
74 | + errorCount++; | ||
75 | + exit(ERRX); | ||
76 | + } | ||
77 | JzipAdd(fullfn, tempfn, zipfile, compression_level); | ||
78 | |||
79 | /* Add the rsa/dsa file to the zip archive normally */ | ||
80 | if (!xpi_arc) { | ||
81 | /* rsa/dsa to zip */ | ||
82 | - sprintf(tempfn, "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa" | ||
83 | - : "rsa")); | ||
84 | - sprintf(fullfn, "%s/%s", tree, tempfn); | ||
85 | + count = snprintf(tempfn, sizeof(tempfn), "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa" : "rsa")); | ||
86 | + if (count >= sizeof(tempfn)) { | ||
87 | + PR_fprintf(errorFD, "unable to write key metadata\n"); | ||
88 | + errorCount++; | ||
89 | + exit(ERRX); | ||
90 | + } | ||
91 | + count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn); | ||
92 | + if (count >= sizeof(fullfn)) { | ||
93 | + PR_fprintf(errorFD, "unable to write key metadata\n"); | ||
94 | + errorCount++; | ||
95 | + exit(ERRX); | ||
96 | + } | ||
97 | JzipAdd(fullfn, tempfn, zipfile, compression_level); | ||
98 | } | ||
99 | |||
100 | @@ -408,6 +442,7 @@ static int | ||
101 | manifesto_xpi_fn(char *relpath, char *basedir, char *reldir, char *filename, void *arg) | ||
102 | { | ||
103 | char fullname[FNSIZE]; | ||
104 | + int count; | ||
105 | |||
106 | if (verbosity >= 0) { | ||
107 | PR_fprintf(outputFD, "--> %s\n", relpath); | ||
108 | @@ -421,7 +456,10 @@ manifesto_xpi_fn(char *relpath, char *basedir, char *reldir, char *filename, voi | ||
109 | if (!PL_HashTableLookup(extensions, ext)) | ||
110 | return 0; | ||
111 | } | ||
112 | - sprintf(fullname, "%s/%s", basedir, relpath); | ||
113 | + count = snprintf(fullname, sizeof(fullname), "%s/%s", basedir, relpath); | ||
114 | + if (count >= sizeof(fullname)) { | ||
115 | + return 1; | ||
116 | + } | ||
117 | JzipAdd(fullname, relpath, zipfile, compression_level); | ||
118 | |||
119 | return 0; | ||
diff --git a/meta/recipes-support/nss/nss_3.35.bb b/meta/recipes-support/nss/nss_3.35.bb index 08e3a06fad..84f1916f30 100644 --- a/meta/recipes-support/nss/nss_3.35.bb +++ b/meta/recipes-support/nss/nss_3.35.bb | |||
@@ -27,6 +27,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${VERSIO | |||
27 | file://pqg.c-ULL_addend.patch \ | 27 | file://pqg.c-ULL_addend.patch \ |
28 | file://Fix-compilation-for-X32.patch \ | 28 | file://Fix-compilation-for-X32.patch \ |
29 | file://nss-build-hacl-poly1305-aarch64.patch \ | 29 | file://nss-build-hacl-poly1305-aarch64.patch \ |
30 | file://0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch \ | ||
30 | " | 31 | " |
31 | 32 | ||
32 | SRC_URI[md5sum] = "9467ec9e65c5aeb3254a50250490f5f7" | 33 | SRC_URI[md5sum] = "9467ec9e65c5aeb3254a50250490f5f7" |