Adding test
/CoreOS/expat/Sanity/handlers
This commit is contained in:
parent
0a8d6aa2af
commit
3df8a592ec
15 changed files with 472 additions and 0 deletions
40
Sanity/handlers/ElementHandler.c
Normal file
40
Sanity/handlers/ElementHandler.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
void XML_startElement (void * userData,
|
||||
const XML_Char * name, const XML_Char ** atts)
|
||||
{
|
||||
printf("Start....... %s\n", name ? name : "<null>");
|
||||
}
|
||||
|
||||
void XML_endElement (void * userData,
|
||||
const XML_Char * name)
|
||||
{
|
||||
printf("End......... %s\n", name ? name : "<null>");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetElementHandler(p, XML_startElement, XML_endElement);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
37
Sanity/handlers/SetCdataSectionHandler.c
Normal file
37
Sanity/handlers/SetCdataSectionHandler.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
void XML_startCdata (void * userData)
|
||||
{
|
||||
}
|
||||
|
||||
void XML_endCdata (void * userData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetCdataSectionHandler(p, XML_startCdata, XML_endCdata);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetCharacterDataHandler.c
Normal file
27
Sanity/handlers/SetCharacterDataHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetCharacterDataHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetCommentHandler.c
Normal file
27
Sanity/handlers/SetCommentHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetCommentHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetDefaultHandler.c
Normal file
27
Sanity/handlers/SetDefaultHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetDefaultHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetDefaultHandlerExpand.c
Normal file
27
Sanity/handlers/SetDefaultHandlerExpand.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetDefaultHandlerExpand(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetExternalEntityRefHandler.c
Normal file
27
Sanity/handlers/SetExternalEntityRefHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetExternalEntityRefHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
Sanity/handlers/SetNamespaceDeclHandler.c
Normal file
39
Sanity/handlers/SetNamespaceDeclHandler.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
void XML_startNamespaceDecl(void *userData,
|
||||
const XML_Char *prefix,
|
||||
const XML_Char *uri)
|
||||
{
|
||||
}
|
||||
|
||||
void XML_endNamespaceDecl (void * userData,
|
||||
const XML_Char * prefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetNamespaceDeclHandler(p, XML_startNamespaceDecl, XML_endNamespaceDecl);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetNotStandaloneHandler.c
Normal file
27
Sanity/handlers/SetNotStandaloneHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetNotStandaloneHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetNotationDeclHandler.c
Normal file
27
Sanity/handlers/SetNotationDeclHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetNotationDeclHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetProcessingInstructionHandler.c
Normal file
27
Sanity/handlers/SetProcessingInstructionHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetProcessingInstructionHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
31
Sanity/handlers/SetUnknownEncodingHandler.c
Normal file
31
Sanity/handlers/SetUnknownEncodingHandler.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void XML_unknownEncoding(void *encodingHandlerData,
|
||||
const XML_Char *name,
|
||||
XML_Encoding *info)
|
||||
{
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
void *encodingHandlerData;
|
||||
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetUnknownEncodingHandler(p, XML_unknownEncoding, encodingHandlerData);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
Sanity/handlers/SetUnparsedEntityDeclHandler.c
Normal file
27
Sanity/handlers/SetUnparsedEntityDeclHandler.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static void default_handler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
fprintf(stderr, "default_handler.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const char pythontest1[] = { '\0', '\r', '\n' };
|
||||
XML_Parser p;
|
||||
|
||||
p = XML_ParserCreate(NULL);
|
||||
|
||||
XML_SetUnparsedEntityDeclHandler(p, default_handler);
|
||||
|
||||
if (XML_Parse(p, pythontest1, 3, 1) == 0)
|
||||
puts("parse fail");
|
||||
|
||||
XML_ParserFree(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
Sanity/handlers/main.fmf
Normal file
25
Sanity/handlers/main.fmf
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
summary: Test for C expat handlers
|
||||
description: |4
|
||||
Jan Lieskovsky <jlieskov@redhat.com>
|
||||
|
||||
C handlers test used for checking CVE-2009-3560. In the future we
|
||||
could expand this for checking valid xml files as well.
|
||||
|
||||
http://www.xml.com/pub/a/1999/09/expat/index.html
|
||||
contact: fhrdina@redhat.com
|
||||
component:
|
||||
- expat
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- expat
|
||||
- expat-devel
|
||||
- gcc
|
||||
duration: 15m
|
||||
enabled: true
|
||||
tag:
|
||||
- Tier1
|
||||
tier: '1'
|
||||
extra-nitrate: TC#0032973
|
||||
extra-summary: /CoreOS/expat/Sanity/handlers
|
||||
extra-task: /CoreOS/expat/Sanity/handlers
|
||||
57
Sanity/handlers/runtest.sh
Executable file
57
Sanity/handlers/runtest.sh
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/expat/Sanity/handlers
|
||||
# Description: Test for C expat handlers
|
||||
# Author: Petr Splichal <psplicha@redhat.com>
|
||||
# Jan Lieskovsky <jlieskov@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="expat"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
||||
rlRun "HandlersList=\`ls *.c | sed 's/\.c$//'\`" \
|
||||
0 "Getting list of handlers"
|
||||
rlRun "cp *.c $TmpDir" 0 "Copying source files"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
for handler in $HandlersList ; do
|
||||
rlRun "gcc $handler.c -o $handler -l expat" 0 "Compiling $handler"
|
||||
rlRun "./$handler" 0 "Testing $handler"
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue