-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from wolkykim/secfix
security update: add sanity check on url decoding
- Loading branch information
Showing
11 changed files
with
410 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
################################################################################ | ||
## qDecoder - http://www.qdecoder.org | ||
## | ||
## Copyright (c) 2000-2022 Seungyoung Kim. | ||
## All rights reserved. | ||
## | ||
## Redistribution and use in source and binary forms, with or without | ||
## modification, are permitted provided that the following conditions are met: | ||
## | ||
## 1. Redistributions of source code must retain the above copyright notice, | ||
## this list of conditions and the following disclaimer. | ||
## 2. Redistributions in binary form must reproduce the above copyright notice, | ||
## this list of conditions and the following disclaimer in the documentation | ||
## and/or other materials provided with the distribution. | ||
## | ||
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
## POSSIBILITY OF SUCH DAMAGE. | ||
################################################################################ | ||
|
||
prefix = @prefix@ | ||
exec_prefix = @exec_prefix@ | ||
|
||
## qDecoder definitions | ||
QDECODER_INCDIR = ../src | ||
QDECODER_LIBDIR = ../src | ||
|
||
## Compiler options | ||
CC = @CC@ | ||
CFLAGS = @CFLAGS@ | ||
CPPFLAGS = @CPPFLAGS@ -I${QDECODER_INCDIR} | ||
|
||
TARGETS = \ | ||
test_q_urldecode | ||
QUNIT_OBJS = qunit.o | ||
LIBQDECODER = ${QDECODER_LIBDIR}/libqdecoder.a | ||
|
||
## Main | ||
all: ${TARGETS} | ||
|
||
run: test | ||
test: all | ||
@./launcher.sh ${TARGETS} | ||
|
||
test_q_urldecode: test_q_urldecode.o ${QUNIT_OBJS} | ||
${CC} ${CFLAGS} ${CPPFLAGS} -o $@ test_q_urldecode.o ${QUNIT_OBJS} ${LIBQDECODER} | ||
|
||
## Clear Module | ||
clean: | ||
${RM} *.o ${TARGETS} | ||
|
||
## Compile Module | ||
.c.o: | ||
${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
qDecoder Unit Tests | ||
=================== | ||
|
||
# How to run unit tests. | ||
|
||
``` | ||
$ make test | ||
Test internal.c/_q_urldecode | ||
====================================================================== | ||
* TEST : Test plain string . OK (1 assertions, 0ms) | ||
* TEST : Test urlencoded string . OK (1 assertions, 0ms) | ||
* TEST : Test urlencoded string exceptions .. OK (2 assertions, 0ms) | ||
====================================================================== | ||
PASS - 3/3 tests passed. | ||
``` | ||
|
||
# How to write unit tests | ||
|
||
We need your help in writing unit tests. Please refer qunit.h for your reference. | ||
|
||
```C | ||
#include "qunit.h" | ||
#include "qdecoder.h" | ||
|
||
QUNIT_START("Test title"); | ||
|
||
TEST("Test name1") { | ||
ASSERT_EQUAL_STR("abc", "abc"); | ||
ASSERT_EQUAL_INT(8, 8); | ||
} | ||
|
||
TEST("Test name2") { | ||
ASSERT_EQUAL_PT(NULL == NULL); | ||
} | ||
|
||
QUNIT_END(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
|
||
if [ $# = 0 ]; then | ||
echo "This program is called by make. Please use \"make test\" command instead." | ||
exit 1 | ||
fi | ||
|
||
FAIL=0 | ||
FAILDESC="" | ||
for EXECUTABLE in $*; do | ||
./$EXECUTABLE | ||
if [ $? != 0 ]; then | ||
FAIL=1 | ||
FAILDESC="$FAILDESC $EXECUTABLE" | ||
fi | ||
echo "" | ||
done | ||
|
||
if [ $FAIL != 0 ]; then | ||
echo "======================================================================" | ||
echo "**** OOOOOPS!!! UNSUCESSFUL UNIT TEST FOUND. PLEASE FIX AND RERUN ****" | ||
echo "======================================================================" | ||
echo "Fails in =>$FAILDESC" | ||
exit 1 | ||
fi | ||
|
||
echo "======================================================================" | ||
echo "**** Good job! All tests are successful ****" | ||
echo "======================================================================" | ||
echo "* ____ _ All tests have finished successfully. *" | ||
echo "* / ___| ___ ___ __| | | | ___ | |__ | | *" | ||
echo "* | | _ / _ \ / _ \ / _\` | _ | |/ _ \| '_ \ | | *" | ||
echo "* | |_| | (_) | (_) | (_| | | |_| | (_) | |_) | |_| *" | ||
echo "* \____|\___/ \___/ \__,_| \___/ \___/|_.__/ (_) *" | ||
echo "======================================================================" | ||
echo "Tested: $*" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/****************************************************************************** | ||
* qunit - C Unit Test Framework | ||
* | ||
* Copyright (c) 2014-2022 Seungyoung Kim. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*****************************************************************************/ | ||
|
||
#include <stdio.h> | ||
#include <sys/time.h> | ||
|
||
/** | ||
* Returns the current time in milliseconds. | ||
* | ||
* @return current time in milliseconds. | ||
*/ | ||
long _qunit_current_milli(void) { | ||
struct timeval tv; | ||
gettimeofday(&tv, NULL); | ||
long time = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); | ||
return time; | ||
} |
Oops, something went wrong.