Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1182667 - Enable warnings as errors, r=rrelyea
  • Loading branch information
martinthomson committed Aug 17, 2015
1 parent 2b9edbc commit 718ebbc
Show file tree
Hide file tree
Showing 192 changed files with 1,354 additions and 1,506 deletions.
35 changes: 16 additions & 19 deletions cmd/bltest/blapitest.c
Expand Up @@ -56,8 +56,7 @@ char *testdir = NULL;
#define TIMEMARK(seconds) \
time1 = PR_SecondsToInterval(seconds); \
{ \
PRInt64 tmp, L100; \
LL_I2L(L100, 100); \
PRInt64 tmp; \
if (time2 == 0) { \
time2 = 1; \
} \
Expand Down Expand Up @@ -313,19 +312,18 @@ serialize_key(SECItem *it, int ni, PRFileDesc *file)
{
unsigned char len[4];
int i;
SECStatus status;
NSSBase64Encoder *cx;
cx = NSSBase64Encoder_Create(output_ascii, file);
for (i=0; i<ni; i++, it++) {
len[0] = (it->len >> 24) & 0xff;
len[1] = (it->len >> 16) & 0xff;
len[2] = (it->len >> 8) & 0xff;
len[3] = (it->len & 0xff);
status = NSSBase64Encoder_Update(cx, len, 4);
status = NSSBase64Encoder_Update(cx, it->data, it->len);
NSSBase64Encoder_Update(cx, len, 4);
NSSBase64Encoder_Update(cx, it->data, it->len);
}
status = NSSBase64Encoder_Destroy(cx, PR_FALSE);
status = PR_Write(file, "\r\n", 2);
NSSBase64Encoder_Destroy(cx, PR_FALSE);
PR_Write(file, "\r\n", 2);
}

void
Expand Down Expand Up @@ -1436,7 +1434,7 @@ bltest_aes_init(bltestCipherInfo *cipherInfo, PRBool encrypt)
int minorMode;
int i;
int keylen = aesp->key.buf.len;
int blocklen = AES_BLOCK_SIZE;
unsigned int blocklen = AES_BLOCK_SIZE;
PRIntervalTime time1, time2;
unsigned char *params;
int len;
Expand Down Expand Up @@ -1635,6 +1633,8 @@ bltest_rsa_init(bltestCipherInfo *cipherInfo, PRBool encrypt)
cipherInfo->cipher.pubkeyCipher = encrypt ? rsa_encryptOAEP
: rsa_decryptOAEP;
break;
default:
break;
}
return SECSuccess;
}
Expand Down Expand Up @@ -2569,8 +2569,6 @@ printPR_smpString(const char *sformat, char *reportStr,
fprintf(stdout, sformat, reportStr);
PR_smprintf_free(reportStr);
} else {
int prnRes;
LL_L2I(prnRes, rNum);
fprintf(stdout, nformat, rNum);
}
}
Expand Down Expand Up @@ -2791,8 +2789,8 @@ mode_str_to_hash_alg(const SECItem *modeStr)
case bltestSHA256: return HASH_AlgSHA256;
case bltestSHA384: return HASH_AlgSHA384;
case bltestSHA512: return HASH_AlgSHA512;
default: return HASH_AlgNULL;
}
return HASH_AlgNULL;
}

void
Expand Down Expand Up @@ -3004,7 +3002,7 @@ blapi_selftest(bltestCipherMode *modes, int numModes, int inoff, int outoff,
bltestIO pt, ct;
bltestCipherMode mode;
bltestParams *params;
int i, j, nummodes, numtests;
unsigned int i, j, nummodes, numtests;
char *modestr;
char filename[256];
PLArenaPool *arena;
Expand Down Expand Up @@ -3457,13 +3455,12 @@ static secuCommandFlag bltest_options[] =

int main(int argc, char **argv)
{
char *infileName, *outfileName, *keyfileName, *ivfileName;
SECStatus rv = SECFailure;

double totalTime;
double totalTime = 0.0;
PRIntervalTime time1, time2;
PRFileDesc *outfile = NULL;
bltestCipherInfo *cipherInfoListHead, *cipherInfo;
bltestCipherInfo *cipherInfoListHead, *cipherInfo = NULL;
bltestIOMode ioMode;
int bufsize, exponent, curThrdNum;
#ifndef NSS_DISABLE_ECC
Expand Down Expand Up @@ -3511,8 +3508,6 @@ int main(int argc, char **argv)

cipherInfo = PORT_ZNew(bltestCipherInfo);
cipherInfoListHead = cipherInfo;
/* set some defaults */
infileName = outfileName = keyfileName = ivfileName = NULL;

/* Check the number of commands entered on the command line. */
commandsEntered = 0;
Expand Down Expand Up @@ -3712,8 +3707,10 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: You must specify a signature file with -f.\n",
progName);

print_usage:
PORT_Free(cipherInfo);
print_usage:
if (cipherInfo) {
PORT_Free(cipherInfo);
}
Usage();
}

Expand Down
152 changes: 35 additions & 117 deletions cmd/certcgi/certcgi.c
Expand Up @@ -356,81 +356,6 @@ find_field_bool(Pair *data,
}
}

static char *
update_data_by_name(Pair *data,
char *field_name,
char *new_data)
/* replaces the data in the data structure associated with
a name with new data, returns null if not found */
{
int i = 0;
int found = 0;
int length = 100;
char *new;

while (return_name(data, i) != NULL) {
if (PORT_Strcmp(return_name(data, i), field_name) == 0) {
new = make_copy_string( new_data, length, '\0');
PORT_Free(return_data(data, i));
found = 1;
(*(data + i)).data = new;
break;
}
i++;
}
if (!found) {
new = NULL;
}
return new;
}

static char *
update_data_by_index(Pair *data,
int n,
char *new_data)
/* replaces the data of a particular index in the data structure */
{
int length = 100;
char *new;

new = make_copy_string(new_data, length, '\0');
PORT_Free(return_data(data, n));
(*(data + n)).data = new;
return new;
}


static Pair *
add_field(Pair *data,
char* field_name,
char* field_data)
/* adds a new name/data pair to the data structure */
{
int i = 0;
int j;
int name_length = 100;
int data_length = 100;

while(return_name(data, i) != NULL) {
i++;
}
j = START_FIELDS;
while ( j < (i + 1) ) {
j = j * 2;
}
if (j == (i + 1)) {
data = (Pair *) PORT_Realloc(data, (j * 2) * sizeof(Pair));
if (data == NULL) {
error_allocate();
}
}
(*(data + i)).name = make_copy_string(field_name, name_length, '\0');
(*(data + i)).data = make_copy_string(field_data, data_length, '\0');
(data + i + 1)->name = NULL;
return data;
}


static CERTCertificateRequest *
makeCertReq(Pair *form_data,
int which_priv_key)
Expand Down Expand Up @@ -527,10 +452,6 @@ MakeV1Cert(CERTCertDBHandle *handle,
PRExplodedTime printableTime;
PRTime now,
after;
SECStatus rv;



if ( !selfsign ) {
issuerCert = CERT_FindCertByNameString(handle, issuerNameStr);
if (!issuerCert) {
Expand All @@ -539,7 +460,7 @@ MakeV1Cert(CERTCertDBHandle *handle,
}
}
if (find_field_bool(data, "manValidity", PR_TRUE)) {
rv = DER_AsciiToTime(&now, find_field(data, "notBefore", PR_TRUE));
(void)DER_AsciiToTime(&now, find_field(data, "notBefore", PR_TRUE));
} else {
now = PR_Now();
}
Expand All @@ -550,7 +471,7 @@ MakeV1Cert(CERTCertDBHandle *handle,
PR_ExplodeTime (now, PR_GMTParameters, &printableTime);
}
if (find_field_bool(data, "manValidity", PR_TRUE)) {
rv = DER_AsciiToTime(&after, find_field(data, "notAfter", PR_TRUE));
(void)DER_AsciiToTime(&after, find_field(data, "notAfter", PR_TRUE));
PR_ExplodeTime (after, PR_GMTParameters, &printableTime);
} else {
printableTime.tm_month += 3;
Expand Down Expand Up @@ -591,7 +512,7 @@ get_serial_number(Pair *data)
if (ferror(serialFile) != 0) {
error_out("Error: Unable to read serial number file");
}
if (serial == 4294967295) {
if (serial == -1) {
serial = 21;
}
fclose(serialFile);
Expand Down Expand Up @@ -1417,52 +1338,49 @@ string_to_ipaddress(char *string)
return ipaddress;
}

static int
chr_to_hex(char c) {
if (isdigit(c)) {
return c - '0';
}
if (isxdigit(c)) {
return toupper(c) - 'A' + 10;
}
return -1;
}

static SECItem *
string_to_binary(char *string)
string_to_binary(char *string)
{
SECItem *rv;
int high_digit;
int low_digit;

rv = (SECItem *) PORT_ZAlloc(sizeof(SECItem));
if (rv == NULL) {
error_allocate();
}
rv->data = (unsigned char *) PORT_ZAlloc((PORT_Strlen(string))/3 + 2);
while (!isxdigit(*string)) {
rv->len = 0;
while (*string && !isxdigit(*string)) {
string++;
}
rv->len = 0;
while (*string != '\0') {
if (isxdigit(*string)) {
if (*string >= '0' && *string <= '9') {
high_digit = *string - '0';
} else {
*string = toupper(*string);
high_digit = *string - 'A' + 10;
}
string++;
if (*string >= '0' && *string <= '9') {
low_digit = *string - '0';
} else {
*string = toupper(*string);
low_digit = *string - 'A' + 10;
}
(rv->len)++;
} else {
if (*string == ':') {
string++;
} else {
if (*string == ' ') {
while (*string == ' ') {
string++;
}
}
if (*string != '\0') {
error_out("ERROR: Improperly formated binary encoding");
}
}
}
while (*string) {
int high, low;
high = chr_to_hex(*string++);
low = chr_to_hex(*string++);
if (high < 0 || low < 0) {
error_out("ERROR: Improperly formated binary encoding");
}
rv->data[(rv->len)++] = high << 4 | low;
if (*string != ':') {
break;
}
++string;
}
while (*string == ' ') {
++string;
}
if (*string) {
error_out("ERROR: Junk after binary encoding");
}

return rv;
Expand Down
5 changes: 1 addition & 4 deletions cmd/checkcert/checkcert.c
Expand Up @@ -122,7 +122,6 @@ OurVerifyData(unsigned char *buf, int len, SECKEYPublicKey *key,
SECStatus rv;
VFYContext *cx;
SECOidData *sigAlgOid, *oiddata;
SECOidTag sigAlgTag;
SECOidTag hashAlgTag;
int showDigestOid=0;

Expand All @@ -134,8 +133,6 @@ OurVerifyData(unsigned char *buf, int len, SECKEYPublicKey *key,
sigAlgOid = SECOID_FindOID(&sigAlgorithm->algorithm);
if (sigAlgOid == 0)
return SECFailure;
sigAlgTag = sigAlgOid->offset;


if (showDigestOid) {
oiddata = SECOID_FindOIDByTag(hashAlgTag);
Expand Down Expand Up @@ -388,7 +385,7 @@ int main(int argc, char **argv)

SECU_RegisterDynamicOids();
rv = SECU_PrintSignedData(stdout, &derCert, "Certificate", 0,
SECU_PrintCertificate);
(SECU_PPFunc)SECU_PrintCertificate);

if (rv) {
fprintf(stderr, "%s: Unable to pretty print cert. Error: %d\n",
Expand Down

0 comments on commit 718ebbc

Please sign in to comment.