htdocs: removed archive

This commit is contained in:
Daniel Marjamäki 2013-10-12 14:48:52 +02:00
parent 0b9d0e48cf
commit d45d32d9dd
17 changed files with 1 additions and 5973 deletions

View File

@ -1,24 +0,0 @@
all:
gcc -std=c99 -o addfile.cgi addfile.c validatexml.c
gcc -std=c99 -Wno-attributes -o createzip.cgi createzip.c validatexml.c
gcc -std=c99 -o deletefile.cgi deletefile.c validatexml.c
gcc -std=c99 -o edit.cgi edit.c validatexml.c
gcc -std=c99 -o renamefile.cgi renamefile.c validatexml.c
gcc -std=c99 -o report.cgi report.c validatexml.c
gcc -std=c99 -o setfiledata.cgi setfiledata.c validatexml.c
movecgi: all
mv addfile.cgi /home/project-web/cppcheck/cgi-bin/
chmod +rx /home/project-web/cppcheck/cgi-bin/addfile.cgi
mv createzip.cgi /home/project-web/cppcheck/cgi-bin/archive.zip
chmod +rx /home/project-web/cppcheck/cgi-bin/archive.zip
mv deletefile.cgi /home/project-web/cppcheck/cgi-bin/
chmod +rx /home/project-web/cppcheck/cgi-bin/deletefile.cgi
mv edit.cgi /home/project-web/cppcheck/cgi-bin/
chmod +rx /home/project-web/cppcheck/cgi-bin/edit.cgi
mv renamefile.cgi /home/project-web/cppcheck/cgi-bin/
chmod +rx /home/project-web/cppcheck/cgi-bin/renamefile.cgi
mv report.cgi /home/project-web/cppcheck/cgi-bin/
chmod +rx /home/project-web/cppcheck/cgi-bin/report.cgi
mv setfiledata.cgi /home/project-web/cppcheck/cgi-bin/
chmod +rx /home/project-web/cppcheck/cgi-bin/setfiledata.cgi

View File

@ -1,72 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "webarchive.h"
const char *validate(const char *data)
{
int i;
if (strncmp(data,"name=",5) != 0)
return "invalid query string: must start with 'name='";
i = 5;
while (isalnum(data[i]))
i++;
if (i == 5)
return "invalid query string: no name";
if (i > 35)
return "invalid query string: max name size is 32";
if (data[i] == '\0')
return NULL;
if (data[i] != '&')
return "invalid query string: only alphanumeric characters are allowed in the name";
if (strncmp(data+i,"&data=",6)!=0)
return "invalid query string";
i += 6;
// TODO: check XML data..
return NULL;
}
int main()
{
const char *query_string = getenv("QUERY_STRING");
if (query_string == NULL) {
generatepage("Internal error: empty/invalid data");
} else if (strlen(query_string) > MAX_LINE_LEN) {
char errmsg[100] = {0};
sprintf(errmsg, "Internal error: data size limit exceeded (%i)", MAX_LINE_LEN);
generatepage(errmsg);
} else if (NULL != validate(query_string)) {
generatepage(validate(query_string));
} else {
char data[MAX_LINE_LEN] = {0};
unencode(query_string, data);
if (NULL != validate(data)) {
generatepage(validate(data));
} else {
char *olddata[MAX_RECORDS] = {0};
olddata[0] = data;
if (!readdata(&olddata[1], MAX_RECORDS-1)) {
generatepage("Failed to add file (access denied). Try again.");
return EXIT_SUCCESS;
}
sortdata(olddata, MAX_RECORDS);
FILE *f = fopen("data.txt", "wt");
if (f == NULL) {
generatepage("Failed to add file (access denied). Try again.");
return EXIT_SUCCESS;
}
for (int i = 0; i < MAX_RECORDS && olddata[i]; i++)
fprintf(f, "%s\n", olddata[i]);
fclose(f);
generatepage("saved.");
}
}
return EXIT_SUCCESS;
}

View File

@ -1,70 +0,0 @@
#include "webarchive.h"
#include "miniz.c"
#include <stdio.h>
#include <stdlib.h>
#define ALL_ZIP "all.zip"
int main()
{
mz_zip_archive zip_archive = {0};
FILE *f = fopen("data.txt", "rt");
if (f == NULL) {
generatepage("failed to load data");
return EXIT_FAILURE;
}
int first = 1;
char line[MAX_LINE_LEN] = {0};
while (fgets(line,sizeof(line)-2,f)) {
char data[MAX_LINE_LEN] = {0};
unencode(line,data);
const char *xmldata = strstr(data, "&data=");
xmldata = xmldata ? (xmldata + 6) : "";
char name[MAX_NAME_LEN+20];
if (strstr(xmldata, "<rule>"))
sprintf(name, "archive/%s.rule", getname(line));
else
sprintf(name, "archive/%s.cfg", getname(line));
if (first == 1) {
first = 0;
if (!mz_zip_writer_init_file(&zip_archive, ALL_ZIP, 0)) {
generatepage("internal error: init_file failed");
return EXIT_FAILURE;
}
if (!mz_zip_writer_add_mem_ex(&zip_archive, name, xmldata, strlen(xmldata), NULL, 0U, MZ_BEST_COMPRESSION, 0, 0)) {
generatepage("internal error: add_mem_ex failed");
return EXIT_FAILURE;
}
if (!mz_zip_writer_finalize_archive(&zip_archive)) {
generatepage("internal error: finalize_archive failed");
return EXIT_FAILURE;
}
if (!mz_zip_writer_end(&zip_archive)) {
generatepage("internal error: writer_end failed");
return EXIT_FAILURE;
}
} else if (!mz_zip_add_mem_to_archive_file_in_place(ALL_ZIP, name, xmldata, strlen(xmldata), NULL, 0U, MZ_BEST_COMPRESSION)) {
generatepage("failed to add data");
return EXIT_FAILURE;
}
}
fclose(f);
f = fopen("all.zip","rb");
if (!f) {
generatepage("internal error: failed to load zip");
return EXIT_FAILURE;
}
puts("Content-type: application/zip\r\n\r");
int c;
while ((c = fgetc(f)) != EOF)
putc(c,stdout);
return EXIT_SUCCESS;
}

View File

@ -1,66 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "webarchive.h"
int main()
{
const char *query_string = getenv("QUERY_STRING");
if (query_string == NULL) {
generatepage("Internal error: invalid request");
return EXIT_SUCCESS;
}
if (NULL != validate_name_version(query_string)) {
generatepage(validate_name_version(query_string));
return EXIT_SUCCESS;
}
char *data[MAX_RECORDS] = {0};
if (!readdata(data, MAX_RECORDS)) {
generatepage("Failed to delete file, try again");
return EXIT_SUCCESS;
}
sortdata(data, MAX_RECORDS);
char name[MAX_NAME_LEN] = {0};
strcpy(name, getname(query_string));
int index = -1;
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (strcmp(name, getname(data[i])) == 0) {
index = i;
break;
}
}
if (index == -1) {
generatepage("File not found");
return EXIT_SUCCESS;
}
if (strcmp(name,"gtk")==0 || strcmp(name,"windows")==0) {
generatepage("Permission denied to delete this file");
return EXIT_SUCCESS;
}
FILE *f = fopen("data.txt", "wt");
if (f == NULL) {
generatepage("Failed to delete file (access denied)");
return EXIT_SUCCESS;
}
int deleted = 0;
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (i != index)
fprintf(f, "%s\n", data[i]);
else
deleted = 1;
}
fclose(f);
generatepage(deleted ? "File deleted" : "Failed to delete file");
return EXIT_SUCCESS;
}

View File

@ -1,67 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "webarchive.h"
int main()
{
const char *query_string = getenv("QUERY_STRING");
if (query_string == NULL) {
generatepage("Internal error: invalid request");
return EXIT_SUCCESS;
}
if (NULL != validate_name_version(query_string)) {
generatepage(validate_name_version(query_string));
return EXIT_SUCCESS;
}
char *data[MAX_RECORDS] = {0};
if (!readdata(data, MAX_RECORDS)) {
generatepage("Failed to read file data");
return EXIT_SUCCESS;
}
char name[MAX_NAME_LEN] = {0};
strcpy(name, getname(query_string));
int index = -1;
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (strcmp(name, getname(data[i])) == 0) {
index = i;
break;
}
}
if (index == -1) {
generatepage("File not found");
return EXIT_SUCCESS;
}
int version = getversion(data[index]);
if (version < 1)
version = 1;
const char *olddata = strstr(data[index], "&data=");
if (olddata) {
char *temp = malloc(strlen(olddata+6));
unencode(olddata+6, temp);
olddata = temp;
} else
olddata = "";
puts("Content-type: text/html\r\n\r\n");
puts("<html>");
puts("<body>");
puts(" <form action=\"http://cppcheck.sourceforge.net/cgi-bin/setfiledata.cgi\" method=\"get\">");
printf(" <textarea name=\"name\" cols=\"30\" rows=\"1\" readonly>%s</textarea>\n",name);
printf(" <textarea name=\"version\" cols=\"30\" rows=\"1\" readonly>%i</textarea><br>\n",1+version);
printf(" <textarea name=\"data\" cols=\"60\" rows=\"20\" maxsize=\"512\">%s</textarea><br>\n",olddata);
puts(" <input type=\"submit\" value=\"Save\">");
puts(" </form>");
puts("</body>");
puts("</html>");
return EXIT_SUCCESS;
}

View File

@ -1,60 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Cppcheck is an analysis tool for C/C++ code.
It detects the types of bugs that the compilers normally fail to detect. The
goal is no false positives." />
<meta name="keywords" content="Cppcheck, open source, analysis tool, C/C++,
code, errors, bugs, compilers, bounds checking, memory leaks, obsolete functions,
uninitialized variables, unused functions" />
<title>Cppcheck - Archive</title>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Orbitron&amp;text=Cppcheck" />
<link rel="stylesheet" type="text/css" href="/site/css/pack.css" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="alternate" type="application/rss+xml" title="Project News"
href="http://sourceforge.net/p/cppcheck/news/feed" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
window.jQuery || document.write('<script type="text/javascript" src="/site/js/jquery-1.10.2.min.js"><\/script>')
//]]>
</script>
<script src="/site/js/pack.js" type="text/javascript"></script></head>
<body>
<div id="header">
<div class="wrap">
<h1><a href="/">Cppcheck</a></h1>
<p>A tool for static C/C++ code analysis</p>
</div> <!-- .wrap -->
</div> <!-- #header -->
<div id="tabs">
<div class="wrap">
<ul>
<li><a href="/">Home</a></li>
<li><a href="http://sourceforge.net/apps/mediawiki/cppcheck/">Wiki</a></li>
<li><a href="http://sourceforge.net/apps/phpbb/cppcheck/">Forum</a></li>
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Issues</a></li>
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
<li><a href="/demo/">Online Demo</a></li>
<li><strong><a href="/archive/">Archive</a></strong></li>
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
</ul>
</div> <!-- .wrap -->
</div> <!-- #tabs -->
<div id="content">
<div class="wrap">
<h1>Cppcheck - Archive</h1>
<p>This archive is for useful Cppcheck rules and library configuration files.</p>
<p> If you have a rule or library configuration that you want to share, use this
archive. Feel free to add any library or rule here.</p>
<?php virtual('../cgi-bin/report.cgi') ?>
<p><a href="/cgi-bin/archive.zip">Download all</a></p>
</div> <!-- .wrap -->
</div> <!-- #content -->
<?php include_once("../analyticstracking.php") ?>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,98 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "webarchive.h"
const char *validate(const char *data)
{
int i;
// name1
if (strncmp(data,"name1=",6) != 0)
return "invalid query string: must start with 'name1='";
i = 6;
while (isalnum(data[i]))
i++;
if (i == 6)
return "invalid query string: no name1";
if (i > 36)
return "invalid query string: max name1 size is 30";
// name2
const int i1 = i;
if (strncmp(data+i,"&name2=",7) != 0)
return "invalid query string: no name2";
i += 7;
if (!isalnum(data[i]))
return "invalid query string: empty name2";
while (isalnum(data[i]))
i++;
if (i - i1 > 37)
return "invalid query string: max name2 size is 30";
if (data[i] != '\0')
return "invalid query string: invalid char in name2";
return NULL;
}
int main()
{
const char *query_string = getenv("QUERY_STRING");
if (query_string == NULL) {
generatepage("Internal error: empty/invalid data");
} else if (NULL != validate(query_string)) {
generatepage(validate(query_string));
} else {
char *data[MAX_RECORDS] = {0};
if (!readdata(data, MAX_RECORDS)) {
generatepage("access failed, try again");
return EXIT_SUCCESS;
}
sortdata(data, MAX_RECORDS);
// Get name1 and name2..
char buf[strlen(query_string)];
strcpy(buf, query_string);
const char * const name1 = strstr(buf, "name1=") + 6;
const char * const name2 = strstr(buf, "name2=") + 6;
for (int i = 0; buf[i] != '\0'; i++) {
if (buf[i] == '&')
buf[i] = '\0';
}
int index = -1;
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (strcmp(name1, getname(data[i])) == 0) {
index = i;
break;
}
}
if (index == -1) {
generatepage("file not found");
return EXIT_SUCCESS;
}
FILE *f = fopen("data.txt", "wt");
if (f == NULL) {
generatepage("failed to rename file (access denied), try again");
return EXIT_SUCCESS;
}
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (i == index)
fprintf(f, "name=%s%s\n", name2, data[i]+5+strlen(name1));
else
fprintf(f, "%s\n", data[i]);
}
fclose(f);
generatepage("file renamed");
}
return EXIT_SUCCESS;
}

View File

@ -1,75 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "webarchive.h"
#define MAX_RECORDS 1000
void listAll(char **data)
{
puts("Content-type: text/html\r\n\r\n");
puts("<input type=\"button\" onclick=\"addFile()\" value=\"Add file\"/>");
puts("<br /><table border=\"1\"><tr><td><table>");
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
const char *name = getname(data[i]);
int version = getversion(data[i]);
if (version < 0)
version = time(0);
if (i > 0)
printf("<tr height=\"1\"><td colspan=\"2\" bgcolor=\"gray\"></td></tr>");
printf("<tr><td width=\"200\">%s</td>", name);
printf("<td><input type=\"button\" onclick=\"editFile(\'%s\','%i')\" value=\"Edit\"/>", name, version);
printf("<input type=\"button\" onclick=\"renameFile(\'%s\','%i')\" value=\"Rename\"/>", name, version);
if (strcmp(name,"gtk")==0 || strcmp(name,"windows")==0)
printf("<font color=\"gray\">Delete</font>");
else
printf("<input type=\"button\" onclick=\"deleteFile(\'%s\','%i')\" value=\"Delete\"/>&nbsp;</td>", name, version);
printf("</tr>\n");
}
puts("</table></td></tr></table>");
}
void listOne(char **data, const char name[])
{
int index = -1;
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (strcmp(getname(data[i]), name)==0) {
index = i;
break;
}
}
puts("Content-type: text/plain\r\n\r\n");
puts((index == -1) ? "Not found" : data[index]);
}
int main()
{
char *data[MAX_RECORDS] = {0};
// read
if (!readdata(data, MAX_RECORDS)) {
puts("Content-type: text/html\r\n\r\n");
puts("Internal error: failed to load data");
return 0;
}
// sort
sortdata(data,MAX_RECORDS);
const char *query_string = getenv("QUERY_STRING");
if (query_string == NULL || *query_string == '\0') {
listAll(data);
} else if (strncmp(query_string, "name=", 5) == 0 && getname(query_string) != NULL) {
char name[MAX_NAME_LEN] = {0};
strcpy(name, getname(query_string));
listOne(data,name);
} else {
puts("Content-type: text/plain\r\n\r\n");
puts("Invalid query");
}
return 0;
}

View File

@ -1,72 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "webarchive.h"
int main()
{
const char *query_string = getenv("QUERY_STRING");
if (query_string == NULL) {
generatepage("Internal error: invalid request");
return EXIT_SUCCESS;
}
if (NULL != validate_name_version_data(query_string)) {
generatepage(validate_name_version_data(query_string));
return EXIT_SUCCESS;
}
char *data[MAX_RECORDS] = {0};
if (!readdata(data, MAX_RECORDS)) {
generatepage("Failed to read file data");
return EXIT_SUCCESS;
}
char name[MAX_NAME_LEN] = {0};
strcpy(name, getname(query_string));
int index = -1;
for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
if (strcmp(name, getname(data[i])) == 0) {
index = i;
break;
}
}
if (index == -1) {
generatepage("File not found");
return EXIT_SUCCESS;
}
// cleanup data...
char str[MAX_LINE_LEN] = {0};
char *dst = str;
for (const char *src = query_string; *src; src++) {
*dst = *src;
dst++;
if (strncmp(src, "%25", 3) == 0 && isxdigit(src[3]) && isxdigit(src[4]))
src += 2;
}
data[index] = str;
sortdata(data, MAX_RECORDS);
FILE *f = fopen("data.txt", "wt");
if (f == NULL) {
generatepage("Failed to add file (access denied). Try again.");
return EXIT_SUCCESS;
}
for (int i = 0; i < MAX_RECORDS && data[i]; i++)
fprintf(f, "%s\n", data[i]);
fclose(f);
generatepage("saved.");
f = fopen("setfiledata.log", "at");
if (f) {
fprintf(f,"%s\n",str);
fclose(f);
}
return EXIT_SUCCESS;
}

View File

@ -1,113 +0,0 @@
#include "validatexml.h"
#include <string.h>
#include <stdio.h>
#include <ctype.h>
void skipspaces(const char xmldata[], int *pos, int *linenr)
{
const char *p = &xmldata[*pos];
while (isspace(*p) || *p == '\r' || *p == '\n') {
if (strncmp(p,"\r\n",2)==0)
++p;
if (*p == '\r' || *p == '\n')
++(*linenr);
++p;
}
*pos = p - xmldata;
}
int validatexml(const char xmldata[])
{
if (strncmp(xmldata,"<?xml version=\"1.0\"?>",21)!=0)
return 1;
int linenr = 1;
char elementNames[10][64]; // only 10 element levels handled
int level = 0;
for (int pos = 21; xmldata[pos]; pos++) {
if (strncmp(&xmldata[pos], "\r\n", 2)==0) {
++linenr;
++pos;
} else if (xmldata[pos]=='\r' || xmldata[pos]=='\n') {
++linenr;
} else if (xmldata[pos] == '<') {
// found a element, validate it
++pos;
skipspaces(xmldata,&pos,&linenr);
// is this a end-element?
if (xmldata[pos] == '/') {
// end element without any previous start element
if (level <= 0) {
return linenr;
}
--level;
// compare name of end element with name of start element
int len = strlen(elementNames[level]);
if (strncmp(&xmldata[pos+1],elementNames[level],len)!=0 || xmldata[pos+1+len]!='>')
return linenr;
pos += 1 + len;
} else {
// this validator allows max 8 element levels
if (level > 8)
return linenr;
if (!isalpha(xmldata[pos]))
return linenr;
// add element name to elementNames so it can be compared later against the end element
memset(elementNames[level], 0, 64);
for (int i = 0; i < 64; i++) {
if ((xmldata[pos+i]>='a' && xmldata[pos+i]<='z') || xmldata[pos+i] == '-')
elementNames[level][i] = xmldata[pos+i];
else {
pos += i;
break;
}
}
if (!strchr("/> \r\n", xmldata[pos]))
return linenr;
level++;
// validate all attributes
while (xmldata[pos] != '/' && xmldata[pos] != '>') {
// validate one attribute
skipspaces(xmldata,&pos,&linenr);
if ((xmldata[pos] >= 'a') && xmldata[pos] <= 'z') {
// attribute name
while (((xmldata[pos] >= 'a') && xmldata[pos] <= 'z') || xmldata[pos] == '-')
++pos;
if (xmldata[pos++] != '=')
return linenr;
if (xmldata[pos++] != '\"')
return linenr;
// attribute value
while (isalnum(xmldata[pos]) || strchr(":-.,_",xmldata[pos]))
++pos;
if (xmldata[pos++] != '\"')
return linenr;
if (!strchr("> \r\n", xmldata[pos]))
return linenr;
} else if (xmldata[pos] != '/' && xmldata[pos] != '>') {
return linenr;
}
}
// no end element.. <abc/>
if (xmldata[pos] == '/') {
--level;
++pos;
skipspaces(xmldata,&pos,&linenr);
if (xmldata[pos] != '>')
return linenr;
}
}
} else if (xmldata[pos] == '>') {
return linenr;
}
}
if (level != 0)
return linenr;
return -1;
}

View File

@ -1,7 +0,0 @@
#ifndef VALIDATEXMLH
#define VALIDATEXMLH
/** validate xml data */
int validatexml(const char xmldata[]);
#endif

View File

@ -1,190 +0,0 @@
#include "validatexml.h"
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_RECORDS 1000
#define MAX_LINE_LEN 0xffff
#define MAX_NAME_LEN 32
static void unencode(const char *src, char *dest)
{
for (; *src; src++, dest++) {
if (*src == '+')
*dest = ' ';
else if (*src == '%') {
int code;
if (sscanf(src+1, "%2x", &code) != 1)
code = '?';
if (code == '%' && isxdigit(src[3]) && isxdigit(src[4])) {
src += 2;
sscanf(src+1, "%2x", &code);
}
*dest = code;
src += 2;
} else
*dest = *src;
}
*dest = '\0';
}
int readdata(char ** const data, int sz)
{
FILE *f = fopen("data.txt", "rt");
if (!f)
return 0; // failed
char line[MAX_LINE_LEN] = {0};
int i = 0;
while (i < sz && fgets(line,sizeof(line)-2,f)) {
if (strncmp(line, "name=", 5) == 0) {
int len = strlen(line);
while (line[len-1] == '\n' || line[len-1] == '\r' || line[len-1] == '\t' || line[len-1] == ' ')
line[--len] = '\0';
data[i] = malloc(len);
strcpy(data[i], line);
i++;
}
}
fclose(f);
return 1; // success
}
const char * getname(const char *data)
{
static char name[32];
if (strncmp(data,"name=",5) != 0)
return NULL;
int i = 0;
while (i < sizeof(name) && data[i+5] && data[i+5] != '&') {
name[i] = data[i+5];
i++;
}
if (i >= sizeof(name))
return NULL;
while (i < sizeof(name))
name[i++] = 0;
return name;
}
int getversion(const char *data)
{
const char *name = getname(data);
if (name == NULL)
return 0; // invalid string => 0
data = data + strlen("name=") + strlen(name);
if (strncmp(data,"&version=",9) != 0)
return 1; // no version => 1
data = data + 9;
int ret = 0;
while (isdigit(*data)) {
ret = ret * 10 + *data - '0';
data++;
}
if (*data != '\0' && *data != '&')
return -1; // invalid version => -1
return ret;
}
void sortdata(char ** const data, int sz)
{
for (int i = 1; i < sz && data[i]; i++) {
if (strcmp(data[i-1], data[i]) > 0) {
char *p = data[i-1];
data[i-1] = data[i];
data[i] = p;
if (i >= 2)
i -= 2;
}
}
}
void generatepage(const char msg[])
{
puts("Content-type: text/html\r\n\r\n");
puts("<html>");
puts("<head><script type=\"text/javascript\">");
puts("function ok() { window.location = \"http://cppcheck.sourceforge.net/archive/\"; }");
puts("</script></head>");
puts("<body>");
puts(msg);
puts("<br /><input type=\"button\" value=\"OK\" onclick=\"ok()\"></body></html>");
}
const char *validate_name_version(const char *data)
{
int i = 0;
// name
if (strncmp(data,"name=",5) != 0)
return "invalid query string: must start with 'name='";
i += 5;
if (!isalnum(data[i]))
return "invalid query string: no name / invalid character in name";
while (isalnum(data[i]))
i++;
if (i > 35)
return "invalid query string: max name size is 32";
// version
if (strncmp(&data[i], "&version=", 9) != 0)
return "invalid query string: 'version=' not seen at the expected location";
i += strlen("&version=");
if (!isdigit(data[i]))
return "invalid query string: version must consist of digits 0-9";
while (isdigit(data[i]))
i++;
// end
if (data[i] != '\0')
return "invalid query";
return NULL;
}
const char *validate_name_version_data(const char *data)
{
int i = 0;
// name
if (strncmp(data,"name=",5) != 0)
return "invalid query string: must start with 'name='";
i += 5;
if (!isalnum(data[i]))
return "invalid query string: no name / invalid character in name";
while (isalnum(data[i]))
i++;
if (i > 35)
return "invalid query string: max name size is 32";
// version
if (strncmp(&data[i], "&version=", 9) != 0)
return "invalid query string: 'version=' not seen at the expected location";
i += strlen("&version=");
if (!isdigit(data[i]))
return "invalid query string: version must consist of digits 0-9";
while (isdigit(data[i]))
i++;
// filedata
if (strncmp(data+i, "&data=", 6) != 0)
return "invalid query string: 'data=' not seen at the expected location";
i += 6;
// validate xml
char xmldata[strlen(data+i)];
memset(xmldata, 0, strlen(data+i));
unencode(data+i, xmldata);
const int badline = validatexml(xmldata);
if (badline >= 1) {
static char buf[256];
sprintf(buf, "Invalid query: Invalid XML at line %i\n", badline);
return buf;
}
// No error
return NULL;
}

View File

@ -30,7 +30,6 @@
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Issues</a></li>
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
<li><strong><a href="/demo/">Online Demo</a></strong></li>
<li><a href="/archive/">Archive</a></li>
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
</ul>
</div> <!-- .wrap -->

View File

@ -89,7 +89,6 @@
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Issues</a></li>
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
<li><em><a href="/demo/">Online Demo</a></em></li>
<li><a href="/archive/">Archive</a></li>
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
</ul>
</div> <!-- .wrap -->

View File

@ -34,7 +34,6 @@
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Issues</a></li>
<li><strong><a href="/devinfo/" title="Developer Information">Developer Info</a></strong></li>
<li><a href="/demo/">Online Demo</a></li>
<li><a href="/archive/">Archive</a></li>
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
</ul>
</div> <!-- .wrap -->

View File

@ -31,7 +31,6 @@ uninitialized variables, unused functions" />
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Issues</a></li>
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
<li><a href="/demo/">Online Demo</a></li>
<li><a href="/archive/">Archive</a></li>
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
</ul>
</div> <!-- .wrap -->
@ -60,7 +59,7 @@ errors in the code (i.e. have zero false positives).
<h2 id="download">Download</h2>
<p>
<a class="downloadnow" href="http://sourceforge.net/projects/cppcheck/files/cppcheck/1.61/cppcheck-1.61-x86-Setup.msi">
<a class="downloadnow" href="http://sourceforge.net/projects/cppcheck/files/cppcheck/1.62/cppcheck-1.62-x86-Setup.msi">
<span class="downButtonText">Download Now!</span>
<span class="downButtonVersion">Version 1.61 for Windows</span>
</a>