Debian Codegraph @

Xpjproject/tests/fuzz/fuzz-sdp.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <stdio.h>
20 #include <stdint.h>
21 #include <stdlib.h>
22
23 #include <pjmedia.h>
24 #include <pjlib.h>
25
26 #include <pjmedia/sdp.h>
27 #include <pjmedia/sdp_neg.h>
28
29 #define kMinInputLength 10
30 #define kMaxInputLength 5120
31
32 pj_pool_factory *mem;
33
34 int sdp_parser(char *DataFx,size_t Size){
35
36 int ret = 0;
37 pj_pool_t *pool;
38 pjmedia_sdp_session *sdp;
39 pj_status_t status;
40
41 pool = pj_pool_create(mem, "sdp_neg_test", 4000, 4000, NULL);
42
43 status = pjmedia_sdp_parse(pool, DataFx, Size,&sdp);
44
45 if (status != PJ_SUCCESS){
46 ret = 1;
47 goto end;
48 }
49
50 status = pjmedia_sdp_validate(sdp);
51
52 end:
53 pj_pool_release(pool);
54
55 return ret;
56 }
57
58 extern int
59 LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
60 {/*pjproject/pjmedia/src/test/sdp_neg_test.c*/
61
62 if (Size < kMinInputLength || Size > kMaxInputLength){
63 return 1;
64 }
65
66 /*Add Extra byte */
67 char *DataFx;
68 DataFx = (char *)calloc((Size+1),sizeof(char));
69 memcpy((void *)DataFx,(void *)Data,Size);
70
71 /*init*/
72 int ret = 0;
73 pj_caching_pool caching_pool;
74 pj_pool_t *pool;
75
76 pj_init();
77 pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
78 pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL);
79
80 pj_log_set_level(0);
81
82 mem = &caching_pool.factory;
83
84 pjmedia_event_mgr_create(pool, 0, NULL);
85
86 /*Call*/
87 ret = sdp_parser(DataFx,Size);
88
89 /*Free*/
90 pjmedia_event_mgr_destroy(pjmedia_event_mgr_instance());
91 pj_pool_release(pool);
92 pj_caching_pool_destroy(&caching_pool);
93
94 free(DataFx);
95 return ret;
96 }