Navigation Menu

Skip to content

Commit

Permalink
Bug 1307526 - Fix various memcpy() calls r=franziskus
Browse files Browse the repository at this point in the history
Differential Revision: https://nss-dev.phacility.com/D60
  • Loading branch information
Tim Taubert committed Oct 4, 2016
1 parent e22f41b commit 4168e40
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/softoken/legacydb/keydb.c
Expand Up @@ -130,7 +130,9 @@ encode_dbkey(NSSLOWKEYDBKey *dbkey, unsigned char version)
buf[2] = nnlen;

/* copy salt */
PORT_Memcpy(&buf[3], dbkey->salt.data, dbkey->salt.len);
if (dbkey->salt.len > 0) {
PORT_Memcpy(&buf[3], dbkey->salt.data, dbkey->salt.len);
}

/* copy nickname */
PORT_Memcpy(&buf[3 + dbkey->salt.len], nn, nnlen);
Expand Down
6 changes: 4 additions & 2 deletions lib/softoken/legacydb/pcertdb.c
Expand Up @@ -2190,8 +2190,10 @@ EncodeDBSubjectEntry(certDBEntrySubject *entry, PLArenaPool *arena,
tmpbuf += certKeys[i].len;
}
for (i = 0; i < ncerts; i++) {
PORT_Memcpy(tmpbuf, keyIDs[i].data, keyIDs[i].len);
tmpbuf += keyIDs[i].len;
if (keyIDs[i].len) {
PORT_Memcpy(tmpbuf, keyIDs[i].data, keyIDs[i].len);
tmpbuf += keyIDs[i].len;
}
}

if (entry->emailAddrs) {
Expand Down
6 changes: 4 additions & 2 deletions lib/util/secasn1e.c
Expand Up @@ -1420,8 +1420,10 @@ sec_asn1e_encode_item_store(void *arg, const char *buf, unsigned long len,
dest = (SECItem *)arg;
PORT_Assert(dest != NULL);

PORT_Memcpy(dest->data + dest->len, buf, len);
dest->len += len;
if (len > 0) {
PORT_Memcpy(dest->data + dest->len, buf, len);
dest->len += len;
}
}

/*
Expand Down

0 comments on commit 4168e40

Please sign in to comment.