Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 8658967 Details for
Bug 1202868
asn1_fuzz_harness.c
asn1_fuzz_harness.c (text/plain), 1.94 KB, created by
Tyson Smith [:tsmith]
(
hide
)
Description:
asn1_fuzz_harness.c
Filename:
MIME Type:
Creator:
Tyson Smith [:tsmith]
Size:
1.94 KB
patch
obsolete
>/* This Source Code Form is subject to the terms of the Mozilla Public > * License, v. 2.0. If a copy of the MPL was not distributed with this > * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ > >#include <signal.h> >#include <stdio.h> > >#include "secutil.h" >#include "nss.h" >#include "certt.h" >#include "keyhi.h" >#include "pk11pub.h" > > >#define MAX_TEST_SIZE 0xA00000 // 10 MBs should be TONS! >#define PERSIST_MAX 10000 > >unsigned int persist_cnt = 0; > >const SEC_ASN1Template OCTET_STRING_Template[] = { > { SEC_ASN1_OCTET_STRING, 0 }, > { 0 } >}; > >int main(int argc, char** argv) >{ > FILE *fp; > PLArenaPool* temparena = NULL; > SECItem data = { siBuffer, NULL, 0 }; > SECItem output; > unsigned int length = 0; > unsigned char *bytes = NULL; > > if (argc < 2) { > printf("Missing test case name!\n"); > return 1; > } > >try_again: > temparena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); > if (!temparena) { > printf("PORT_NewArena failed!\n"); > return 1; > } > > fp = fopen(argv[1], "rb"); > if (fp == NULL) { > printf("fopen failed!\n"); > return 1; > } > > fseek(fp, 0, SEEK_END); > length = ftell(fp); > if (length > MAX_TEST_SIZE) { > fclose(fp); > printf("test case too large!\n"); > return 1; > } > > bytes = (unsigned char *)malloc(length); > if (bytes == NULL) { > fclose(fp); > printf("failed to malloc bytes\n"); > return 1; > } > > fseek(fp , 0, SEEK_SET); > fread(bytes, 1, length, fp); > fclose(fp); > > memset(&output, 0, sizeof(SECItem)); > data.type = siBuffer; > data.data = bytes; > data.len = length; > > if (SEC_ASN1DecodeItem(temparena, &output, OCTET_STRING_Template, &data) != SECSuccess) { > printf("SEC_ASN1DecodeItem failed!\n"); > } > > if (bytes != NULL) { > free(bytes); > bytes = NULL; > } > > if (temparena != NULL) { > PORT_FreeArena(temparena, PR_FALSE); > temparena = NULL; > } > > if (getenv("AFL_PERSISTENT") && persist_cnt++ < PERSIST_MAX) { > raise(SIGSTOP); > goto try_again; > } > > printf("Done\n"); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 1202868
:
8658396
|
8658421
|
8658805
| 8658967 |
8659375
|
8659376
|
8659378
|
8662125
|
8674441