sha
string
github
string
commit_message
string
git_diff
string
is_security
int64
b1601f9b3c70e777d8edab78b7d18841744323c1
https://github.com/apache/commons-fileupload/commit/b1601f9b3c70e777d8edab78b7d18841744323c1
Use HTTPS links to Apache.
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 3d7495eb1..e3748ff50 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -39,7 +39,7 @@ o FILEUPLOAD-243: Make some MultipartStream private fields final Thanks to Vill For complete information on Apache Commons FileUpload, including instructions on how to submit bug reports, patches, or suggestions for improvement, see the Apache Apache Commons FileUpload website: -http://commons.apache.org/proper/commons-fileupload/ +https://commons.apache.org/proper/commons-fileupload/ ------------------------------------------------------------------------------ @@ -61,7 +61,7 @@ o FILEUPLOAD-279: DiskFileItem can no longer be deserialized, unless a particul For complete information on Apache Commons FileUpload, including instructions on how to submit bug reports, patches, or suggestions for improvement, see the Apache Apache Commons FileUpload website: -http://commons.apache.org/proper/commons-fileupload/ +https://commons.apache.org/proper/commons-fileupload/ ------------------------------------------------------------------------------ @@ -75,7 +75,7 @@ o FILEUPLOAD-272: Performance Improvement in MultipartStream. Prevents a DoS (C For complete information on Apache Commons FileUpload, including instructions on how to submit bug reports, patches, or suggestions for improvement, see the Apache Apache Commons FileUpload website: -http://commons.apache.org/proper/commons-fileupload/ +https://commons.apache.org/proper/commons-fileupload/ ------------------------------------------------------------------------------ @@ -111,5 +111,5 @@ o Correct example in usage documentation so it compiles. For complete information on Apache Commons FileUpload, including instructions on how to submit bug reports, patches, or suggestions for improvement, see the Apache Apache Commons FileUpload website: -http://commons.apache.org/proper/commons-fileupload/ +https://commons.apache.org/proper/commons-fileupload/ diff --git a/pom.xml b/pom.xml index f5c284765..1d94e890c 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ The Apache Commons FileUpload component provides a simple yet flexible means of adding support for multipart file upload functionality to servlets and web applications. </description> - <url>http://commons.apache.org/proper/commons-fileupload/</url> + <url>https://commons.apache.org/proper/commons-fileupload/</url> <inceptionYear>2002</inceptionYear> <developers> diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 4c077f43f..805c7a6e0 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -155,10 +155,10 @@ fix as well as a small number of bugfixes." date="2014-02-07"> commons-io dependency does not get loaded by maven if only dependency to commons-fileupload is specified </action> <action issue="FILEUPLOAD-185" dev="simonetripodi" type="fix" due-to="Sebb"> - http://commons.apache.org/fileupload/index.html is out of date + https://commons.apache.org/fileupload/index.html is out of date </action> <action issue="FILEUPLOAD-186" dev="simonetripodi" type="fix" due-to="Sebb"> - http://commons.apache.org/fileupload/index.html should not mention nightly builds + https://commons.apache.org/fileupload/index.html should not mention nightly builds </action> <action issue="FILEUPLOAD-189" dev="simonetripodi" type="fix" due-to="Gregor K"> DiskFileItemFactory use of FileCleaningTracker is documented or coded wrong - proposal submitted by Jan Novotný diff --git a/src/main/java/org/apache/commons/fileupload2/disk/package-info.java b/src/main/java/org/apache/commons/fileupload2/disk/package-info.java index b00ca035a..f4b5cff03 100644 --- a/src/main/java/org/apache/commons/fileupload2/disk/package-info.java +++ b/src/main/java/org/apache/commons/fileupload2/disk/package-info.java @@ -47,7 +47,7 @@ * </pre> * <p> * Please see the FileUpload - * <a href="http://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> + * <a href="https://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> * for further details and examples of how to use this package. * </p> */ diff --git a/src/main/java/org/apache/commons/fileupload2/package-info.java b/src/main/java/org/apache/commons/fileupload2/package-info.java index f1b85ca7f..486675345 100644 --- a/src/main/java/org/apache/commons/fileupload2/package-info.java +++ b/src/main/java/org/apache/commons/fileupload2/package-info.java @@ -78,7 +78,7 @@ * </p> * <p> * Please see the FileUpload - * <a href="http://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> + * <a href="https://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> * for further details and examples of how to use this package. * </p> */ diff --git a/src/main/java/org/apache/commons/fileupload2/portlet/package-info.java b/src/main/java/org/apache/commons/fileupload2/portlet/package-info.java index b1e9563bb..773f62b49 100644 --- a/src/main/java/org/apache/commons/fileupload2/portlet/package-info.java +++ b/src/main/java/org/apache/commons/fileupload2/portlet/package-info.java @@ -38,7 +38,7 @@ * </pre> * <p> * Please see the FileUpload - * <a href="http://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> + * <a href="https://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> * for further details and examples of how to use this package. * </p> */ diff --git a/src/main/java/org/apache/commons/fileupload2/servlet/package-info.java b/src/main/java/org/apache/commons/fileupload2/servlet/package-info.java index 8250b356b..ac0d885c8 100644 --- a/src/main/java/org/apache/commons/fileupload2/servlet/package-info.java +++ b/src/main/java/org/apache/commons/fileupload2/servlet/package-info.java @@ -38,7 +38,7 @@ * </pre> * <p> * Please see the FileUpload - * <a href="http://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> + * <a href="https://commons.apache.org/fileupload/using.html" target="_top">User Guide</a> * for further details and examples of how to use this package. * </p> */ diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml index 2b1734348..64d1f7c79 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -72,7 +72,7 @@ <p><strong>FileUpload 1.4</strong> - 23 December 2018</p> <ul> <li>Download the binary and source distributions from a mirror site - <a href="http://commons.apache.org/fileupload/download_fileupload.cgi">here</a> + <a href="https://commons.apache.org/fileupload/download_fileupload.cgi">here</a> </li> </ul> <p><strong>FileUpload 1.3.3</strong> - 13 June 2017</p> diff --git a/src/site/xdoc/mail-lists.xml b/src/site/xdoc/mail-lists.xml index 36372ed91..919d74b4b 100644 --- a/src/site/xdoc/mail-lists.xml +++ b/src/site/xdoc/mail-lists.xml @@ -49,7 +49,7 @@ limitations under the License. <section name="Overview"> <p> <a href="index.html">Commons FileUpload</a> shares mailing lists with all the other - <a href="http://commons.apache.org/components.html">Commons Components</a>. + <a href="https://commons.apache.org/components.html">Commons Components</a>. To make it easier for people to only read messages related to components they are interested in, the convention in Commons is to prefix the subject line of messages with the component's name, for example: diff --git a/src/site/xdoc/security-reports.xml b/src/site/xdoc/security-reports.xml index 558410a12..283456fed 100644 --- a/src/site/xdoc/security-reports.xml +++ b/src/site/xdoc/security-reports.xml @@ -49,7 +49,7 @@ <p>For information about reporting or asking questions about security problems, please see the <a - href="http://commons.apache.org/security.html">security page + href="https://commons.apache.org/security.html">security page of the Apache Commons project</a>.</p> <subsection name="Notes on Apache Commons FileUpload 1.3.3">
0
dbc27409bd93109b41551be7aca1f260e96e2a25
https://github.com/univention/univention-corporate-server/commit/dbc27409bd93109b41551be7aca1f260e96e2a25
Bug #52723: fix typo
diff --git a/doc/errata/staging/univention-directory-manager-rest.yaml b/doc/errata/staging/univention-directory-manager-rest.yaml index 13e55fcca2..4b62072f1a 100644 --- a/doc/errata/staging/univention-directory-manager-rest.yaml +++ b/doc/errata/staging/univention-directory-manager-rest.yaml @@ -7,7 +7,7 @@ fix: 9.0.16-12A~4.4.0.202102031538 desc: | This update addresses the following issue(s): * The OpenAPI schema of the UDM REST API now returns "200" as status - code for the retrieval of object ceration templates. + code for the retrieval of object creation templates. * The OpenAPI schema of the UDM REST API now contains "201" as additional possible status code for modify operations. It is returned in case an object was moved.
0
713e8073ecf45623cfc5c918c5cbf700203f46e5
https://github.com/droolsjbpm/jbpm/commit/713e8073ecf45623cfc5c918c5cbf700203f46e5
BZ-1169553 - (CVE-2014-8125) EMBARGOED CVE-2014-8125 jBPM: BPMN2 file processing XXE in Process Execution
diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java index dba4fd0ae1..2faeb4a42e 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java @@ -17,6 +17,8 @@ package org.jbpm.bpmn2; import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.StringReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -26,6 +28,7 @@ import javax.xml.parsers.DocumentBuilderFactory; +import org.drools.core.util.IoUtils; import org.jbpm.bpmn2.handler.ReceiveTaskHandler; import org.jbpm.bpmn2.handler.SendTaskHandler; import org.jbpm.bpmn2.handler.ServiceTaskHandler; @@ -47,6 +50,7 @@ import org.kie.api.KieBase; import org.kie.api.event.process.DefaultProcessEventListener; import org.kie.api.event.process.ProcessStartedEvent; +import org.kie.api.io.Resource; import org.kie.api.io.ResourceType; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.process.ProcessInstance; @@ -884,6 +888,45 @@ public void testSignallingExceptionServiceTask() throws Exception { runTestSignallingExceptionServiceTask(ksession); } + @Test + public void testXXEProcessVulnerability() throws Exception { + Resource processResource = ResourceFactory.newClassPathResource("xxe-protection/BPMN2-XXE-Process.bpmn2"); + + File dtdFile = new File("src/test/resources/xxe-protection/external.dtd"); + assertTrue(dtdFile.exists()); + + String dtdContent = IoUtils.readFileAsString(dtdFile); + dtdContent = dtdContent.replaceAll("@@PATH@@", dtdFile.getParentFile().getAbsolutePath()); + + IoUtils.write(dtdFile, dtdContent.getBytes("UTF-8")); + + byte[] data = IoUtils.readBytesFromInputStream(processResource.getInputStream()); + String processAsString = new String(data, "UTF-8"); + // replace place holders with actual paths + File testFiles = new File("src/test/resources/xxe-protection"); + + assertTrue(testFiles.exists()); + + String path = testFiles.getAbsolutePath(); + processAsString = processAsString.replaceAll("@@PATH@@", path); + + Resource resource = ResourceFactory.newReaderResource(new StringReader(processAsString)); + resource.setSourcePath(processResource.getSourcePath()); + resource.setTargetPath(processResource.getTargetPath()); + + KieBase kbase = createKnowledgeBaseFromResources(resource); + KieSession ksession = createKnowledgeSession(kbase); + ProcessInstance processInstance = ksession.startProcess("async-examples.bp1"); + + String var1 = getProcessVarValue(processInstance, "testScript1"); + String var2 = getProcessVarValue(processInstance, "testScript2"); + + assertNull(var1); + assertNull(var2); + + assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED); + } + public static void runTestSignallingExceptionServiceTask(KieSession ksession) throws Exception { // Setup String eventType = "exception-signal"; diff --git a/jbpm-bpmn2/src/test/resources/xxe-protection/BPMN2-XXE-Process.bpmn2 b/jbpm-bpmn2/src/test/resources/xxe-protection/BPMN2-XXE-Process.bpmn2 new file mode 100644 index 0000000000..1412a5cfaa --- /dev/null +++ b/jbpm-bpmn2/src/test/resources/xxe-protection/BPMN2-XXE-Process.bpmn2 @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE foo [ + <!ELEMENT foo ANY > + <!ENTITY author "JDL"> + <!ENTITY scriptName1 "NewScript1"> + <!ENTITY scriptName2 "NewScript2"> + <!ENTITY xxe1 SYSTEM "file://@@PATH@@/Text1.txt" > + <!ENTITY % extdtd SYSTEM "file://@@PATH@@/external.dtd" > + %extdtd; +]> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" id="_P4xkIF3VEeSfO7lCL83Qdw" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.omg.org/bpmn20" typeLanguage="http://www.java.com/javaTypes"> + <bpmn2:itemDefinition id="_testItem" structureRef="String" /> + <bpmn2:process id="async-examples.bp1" drools:packageName="org.jbpm" drools:version="1.0" name="bp1" isExecutable="true"> + <bpmn2:property id="testScript1" itemSubjectRef="_testItem"/> + <bpmn2:property id="testScript2" itemSubjectRef="_testItem"/> + <bpmn2:startEvent id="_5A035F23-6CA6-4EC4-8EE5-A5E87B0B7C19" drools:bgcolor="#9acd32" drools:selectable="true" name=""> + <bpmn2:outgoing>_43A53630-6A27-4E1C-AD13-F87924127544</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:scriptTask id="_5C1B77ED-96D1-425C-921B-76F58B543385" drools:selectable="true" name="&scriptName1;" scriptFormat="http://www.java.com/java"> + <bpmn2:incoming>_43A53630-6A27-4E1C-AD13-F87924127544</bpmn2:incoming> + <bpmn2:outgoing>_F4203272-5ED9-4E6D-9E23-4A992BA2E9F8</bpmn2:outgoing> + <bpmn2:script>&xxe1;</bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="_43A53630-6A27-4E1C-AD13-F87924127544" drools:bgcolor="#000000" drools:selectable="true" sourceRef="_5A035F23-6CA6-4EC4-8EE5-A5E87B0B7C19" targetRef="_5C1B77ED-96D1-425C-921B-76F58B543385"/> + <bpmn2:scriptTask id="_1C194684-F81D-422A-9073-709E5AAD8398" drools:selectable="true" name="&scriptName2;" scriptFormat="http://www.java.com/java"> + <bpmn2:incoming>_F4203272-5ED9-4E6D-9E23-4A992BA2E9F8</bpmn2:incoming> + <bpmn2:outgoing>_3541D5DD-E7BD-4F2F-8EA1-42D923FF1554</bpmn2:outgoing> + <bpmn2:script>&xxe1;</bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="_F4203272-5ED9-4E6D-9E23-4A992BA2E9F8" drools:bgcolor="#000000" drools:selectable="true" sourceRef="_5C1B77ED-96D1-425C-921B-76F58B543385" targetRef="_1C194684-F81D-422A-9073-709E5AAD8398"/> + <bpmn2:endEvent id="_F0EE04B3-79D8-40BC-8477-022A6CFE2C85" drools:bgcolor="#ff6347" drools:selectable="true" name=""> + <bpmn2:incoming>_3541D5DD-E7BD-4F2F-8EA1-42D923FF1554</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="_3541D5DD-E7BD-4F2F-8EA1-42D923FF1554" drools:bgcolor="#000000" drools:selectable="true" sourceRef="_1C194684-F81D-422A-9073-709E5AAD8398" targetRef="_F0EE04B3-79D8-40BC-8477-022A6CFE2C85"/> + </bpmn2:process> + <bpmndi:BPMNDiagram id="_P4xkIV3VEeSfO7lCL83Qdw"> + <bpmndi:BPMNPlane id="_P4xkIl3VEeSfO7lCL83Qdw" bpmnElement="async-examples.bp1"> + <bpmndi:BPMNShape id="_P4yLMF3VEeSfO7lCL83Qdw" bpmnElement="_5A035F23-6CA6-4EC4-8EE5-A5E87B0B7C19"> + <dc:Bounds height="30.0" width="30.0" x="122.0" y="165.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_P4yLMV3VEeSfO7lCL83Qdw" bpmnElement="_5C1B77ED-96D1-425C-921B-76F58B543385"> + <dc:Bounds height="80.0" width="100.0" x="180.0" y="140.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="_P4yLMl3VEeSfO7lCL83Qdw" bpmnElement="_43A53630-6A27-4E1C-AD13-F87924127544"> + <di:waypoint xsi:type="dc:Point" x="137.0" y="180.0"/> + <di:waypoint xsi:type="dc:Point" x="230.0" y="180.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_P4yLM13VEeSfO7lCL83Qdw" bpmnElement="_1C194684-F81D-422A-9073-709E5AAD8398"> + <dc:Bounds height="80.0" width="100.0" x="325.0" y="140.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="_P4yLNF3VEeSfO7lCL83Qdw" bpmnElement="_F4203272-5ED9-4E6D-9E23-4A992BA2E9F8"> + <di:waypoint xsi:type="dc:Point" x="230.0" y="180.0"/> + <di:waypoint xsi:type="dc:Point" x="375.0" y="180.0"/> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_P4yLNV3VEeSfO7lCL83Qdw" bpmnElement="_F0EE04B3-79D8-40BC-8477-022A6CFE2C85"> + <dc:Bounds height="28.0" width="28.0" x="469.0" y="165.0"/> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="_P4yLNl3VEeSfO7lCL83Qdw" bpmnElement="_3541D5DD-E7BD-4F2F-8EA1-42D923FF1554"> + <di:waypoint xsi:type="dc:Point" x="375.0" y="180.0"/> + <di:waypoint xsi:type="dc:Point" x="483.0" y="179.0"/> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/jbpm-bpmn2/src/test/resources/xxe-protection/Text1.txt b/jbpm-bpmn2/src/test/resources/xxe-protection/Text1.txt new file mode 100644 index 0000000000..bfbc082559 --- /dev/null +++ b/jbpm-bpmn2/src/test/resources/xxe-protection/Text1.txt @@ -0,0 +1,2 @@ +System.out.println("Yikes! This script has been read from Text1.txt via an external entity."); +kcontext.setVariable("testScript1", "XXE issue"); \ No newline at end of file diff --git a/jbpm-bpmn2/src/test/resources/xxe-protection/Text2.txt b/jbpm-bpmn2/src/test/resources/xxe-protection/Text2.txt new file mode 100644 index 0000000000..c8e1b8600e --- /dev/null +++ b/jbpm-bpmn2/src/test/resources/xxe-protection/Text2.txt @@ -0,0 +1,2 @@ +System.out.println("Yikes! This script has been read from Text2.txt via an external entity."); +kcontext.setVariable("testScript2", "XXE issue"); \ No newline at end of file diff --git a/jbpm-bpmn2/src/test/resources/xxe-protection/external.dtd b/jbpm-bpmn2/src/test/resources/xxe-protection/external.dtd new file mode 100644 index 0000000000..3891291ea6 --- /dev/null +++ b/jbpm-bpmn2/src/test/resources/xxe-protection/external.dtd @@ -0,0 +1,2 @@ + <!ENTITY xxe2 SYSTEM "file:///Users/maciejswiderski/Development/git-repos/jbpm-main/jbpm-bpmn2/src/test/resources/xxe-protection/Text2.txt" > +
1
747a67fbab8ff74e4281ecbc947910fba13fd65d
https://github.com/FFmpeg/FFmpeg/commit/747a67fbab8ff74e4281ecbc947910fba13fd65d
fixed one overflow problem Originally committed as revision 553 to svn://svn.ffmpeg.org/ffmpeg/trunk
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index bfbf7118cde6..9d882c6ff7c6 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -1,6 +1,6 @@ /* * MPEG Audio decoder - * Copyright (c) 2001 Gerard Lantau. + * Copyright (c) 2001, 2002 Gerard Lantau. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -127,7 +127,7 @@ static VLC huff_quad_vlc[2]; static UINT16 band_index_long[9][23]; /* XXX: free when all decoders are closed */ #define TABLE_4_3_SIZE (8191 + 16) -static UINT8 *table_4_3_exp; +static INT8 *table_4_3_exp; #if FRAC_BITS <= 15 static UINT16 *table_4_3_value; #else @@ -1955,7 +1955,7 @@ static void compute_imdct(MPADecodeContext *s, } } -#ifdef DEBUG +#if defined(DEBUG) void sample_dump(int fnum, INT32 *tab, int n) { static FILE *files[16], *f; @@ -2168,7 +2168,7 @@ static int mp_decode_layer3(MPADecodeContext *s) } g->scale_factors[j++] = 0; } -#ifdef DEBUG +#if defined(DEBUG) { printf("scfsi=%x gr=%d ch=%d scale_factors:\n", g->scfsi, gr, ch); @@ -2225,7 +2225,7 @@ static int mp_decode_layer3(MPADecodeContext *s) /* XXX: should compute exact size */ for(;j<40;j++) g->scale_factors[j] = 0; -#ifdef DEBUG +#if defined(DEBUG) { printf("gr=%d ch=%d scale_factors:\n", gr, ch); @@ -2242,8 +2242,8 @@ static int mp_decode_layer3(MPADecodeContext *s) if (huffman_decode(s, g, exponents, bits_pos + g->part2_3_length) < 0) return -1; -#if defined(DEBUG) && 0 - sample_dump(3, g->sb_hybrid, 576); +#if defined(DEBUG) + sample_dump(0, g->sb_hybrid, 576); #endif /* skip extension bits */ @@ -2267,7 +2267,7 @@ static int mp_decode_layer3(MPADecodeContext *s) g = &granules[ch][gr]; reorder_block(s, g); -#ifdef DEBUG +#if defined(DEBUG) sample_dump(0, g->sb_hybrid, 576); #endif compute_antialias(s, g);
1
42e7cac6dc3f48df72d3f80e8bc2a073afa2ad10
https://github.com/edx/edx-platform/commit/42e7cac6dc3f48df72d3f80e8bc2a073afa2ad10
BOM-2315 Apply pylint-amnesty.
diff --git a/openedx/core/djangoapps/ace_common/__init__.py b/openedx/core/djangoapps/ace_common/__init__.py index 8d5975ff6d85..be8af743829d 100644 --- a/openedx/core/djangoapps/ace_common/__init__.py +++ b/openedx/core/djangoapps/ace_common/__init__.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured ace_common is a Django App that provides common utilities and templates for edx-platform applications that use ACE as their messaging framework. """ diff --git a/openedx/core/djangoapps/ace_common/message.py b/openedx/core/djangoapps/ace_common/message.py index c2fd91c233a8..86b8525ff9ca 100644 --- a/openedx/core/djangoapps/ace_common/message.py +++ b/openedx/core/djangoapps/ace_common/message.py @@ -8,9 +8,9 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers -class BaseMessageType(MessageType): +class BaseMessageType(MessageType): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, *args, **kwargs): - super(BaseMessageType, self).__init__(*args, **kwargs) + super(BaseMessageType, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments from_address = configuration_helpers.get_value('email_from_address') if from_address: self.options.update({'from_address': from_address}) # pylint: disable=no-member diff --git a/openedx/core/djangoapps/ace_common/settings/common.py b/openedx/core/djangoapps/ace_common/settings/common.py index 994034f7b9e0..d4b010f453ef 100644 --- a/openedx/core/djangoapps/ace_common/settings/common.py +++ b/openedx/core/djangoapps/ace_common/settings/common.py @@ -1,4 +1,4 @@ -def plugin_settings(settings): +def plugin_settings(settings): # lint-amnesty, pylint: disable=missing-function-docstring, missing-module-docstring settings.ACE_ENABLED_CHANNELS = [ 'django_email' ] diff --git a/openedx/core/djangoapps/ace_common/tests/mixins.py b/openedx/core/djangoapps/ace_common/tests/mixins.py index e2d392a488b7..2f40ba2feb3f 100644 --- a/openedx/core/djangoapps/ace_common/tests/mixins.py +++ b/openedx/core/djangoapps/ace_common/tests/mixins.py @@ -67,7 +67,7 @@ def assert_query_string_parameters_equal(self, url, **kwargs): class EmailTemplateTagMixin(object): def setUp(self): - super(EmailTemplateTagMixin, self).setUp() + super(EmailTemplateTagMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments patcher = patch('openedx.core.djangoapps.ace_common.templatetags.ace.get_current_request') self.mock_get_current_request = patcher.start() diff --git a/openedx/core/djangoapps/ace_common/tests/test_message.py b/openedx/core/djangoapps/ace_common/tests/test_message.py index 0f4016af3d6a..5fa68ccc7577 100644 --- a/openedx/core/djangoapps/ace_common/tests/test_message.py +++ b/openedx/core/djangoapps/ace_common/tests/test_message.py @@ -11,7 +11,7 @@ @ddt.ddt -class TestAbsoluteUrl(TestCase): +class TestAbsoluteUrl(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring @ddt.data( ('[email protected]', True), diff --git a/openedx/core/djangoapps/ace_common/tests/test_templatetags.py b/openedx/core/djangoapps/ace_common/tests/test_templatetags.py index 9606b680954c..75c338464bfd 100644 --- a/openedx/core/djangoapps/ace_common/tests/test_templatetags.py +++ b/openedx/core/djangoapps/ace_common/tests/test_templatetags.py @@ -20,7 +20,7 @@ class TestAbsoluteUrl(CacheIsolationTestCase): def setUp(self): self.site = SiteFactory.create() self.site.domain = 'example.com' - super(TestAbsoluteUrl, self).setUp() + super(TestAbsoluteUrl, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments def test_absolute_url(self): absolute = ensure_url_is_absolute(self.site, '/foo/bar') diff --git a/openedx/core/djangoapps/api_admin/api/v1/tests/test_views.py b/openedx/core/djangoapps/api_admin/api/v1/tests/test_views.py index aab2126e120e..0ce9380c068f 100644 --- a/openedx/core/djangoapps/api_admin/api/v1/tests/test_views.py +++ b/openedx/core/djangoapps/api_admin/api/v1/tests/test_views.py @@ -6,7 +6,7 @@ from rest_framework.reverse import reverse -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test import TestCase from openedx.core.djangoapps.api_admin.tests import factories @@ -21,7 +21,7 @@ class ApiAccessRequestViewTests(TestCase): """ password = 'test' - def setUp(self): + def setUp(self): # lint-amnesty, pylint: disable=super-method-not-called """ Perform operations common to all test cases. """ diff --git a/openedx/core/djangoapps/api_admin/forms.py b/openedx/core/djangoapps/api_admin/forms.py index e3bca0be4a49..72653b216bbe 100644 --- a/openedx/core/djangoapps/api_admin/forms.py +++ b/openedx/core/djangoapps/api_admin/forms.py @@ -2,7 +2,7 @@ from django import forms -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.utils.translation import ugettext as _ from openedx.core.djangoapps.api_admin.models import ApiAccessRequest, Catalog @@ -34,7 +34,7 @@ class Meta(object): def __init__(self, *args, **kwargs): # Get rid of the colons at the end of the field labels. kwargs.setdefault('label_suffix', '') - super(ApiAccessRequestForm, self).__init__(*args, **kwargs) + super(ApiAccessRequestForm, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments class ViewersWidget(forms.widgets.TextInput): @@ -61,7 +61,7 @@ def to_python(self, value): return [username.strip() for username in value.split(',')] def validate(self, value): - super(ViewersField, self).validate(value) + super(ViewersField, self).validate(value) # lint-amnesty, pylint: disable=super-with-arguments nonexistent_users = [] for username in value: try: diff --git a/openedx/core/djangoapps/api_admin/management/commands/create_api_access_request.py b/openedx/core/djangoapps/api_admin/management/commands/create_api_access_request.py index a6ad67f0b694..4a7fbb0a354e 100644 --- a/openedx/core/djangoapps/api_admin/management/commands/create_api_access_request.py +++ b/openedx/core/djangoapps/api_admin/management/commands/create_api_access_request.py @@ -4,7 +4,7 @@ import logging from contextlib import contextmanager -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site from django.core.management.base import BaseCommand, CommandError from django.db.models.signals import post_save, pre_save @@ -106,7 +106,7 @@ def get_user(self, username): try: return User.objects.get(username=username) except User.DoesNotExist: - raise CommandError('User {} not found'.format(username)) + raise CommandError('User {} not found'.format(username)) # lint-amnesty, pylint: disable=raise-missing-from def create_api_access_request(self, user, status, reason, website): """ @@ -127,14 +127,14 @@ def create_api_access_request(self, user, status, reason, website): if 'Permission denied' in error_msg and 'mako_lms' in error_msg: logger.warning('Error sending email about access request: {}'.format(error_msg)) else: - raise CommandError(error_msg) + raise CommandError(error_msg) # lint-amnesty, pylint: disable=raise-missing-from except Exception as e: msg = 'Unable to create ApiAccessRequest for {}. Exception is {}: {}'.format( user.username, type(e).__name__, e ) - raise CommandError(msg) + raise CommandError(msg) # lint-amnesty, pylint: disable=raise-missing-from logger.info('Created ApiAccessRequest for user {}'.format(user.username)) @@ -146,7 +146,7 @@ def create_api_access_config(self): _, created = ApiAccessConfig.objects.get_or_create(enabled=True) except Exception as e: msg = 'Unable to create ApiAccessConfig. Exception is {}: {}'.format(type(e).__name__, e) - raise CommandError(msg) + raise CommandError(msg) # lint-amnesty, pylint: disable=raise-missing-from if created: logger.info('Created ApiAccessConfig') diff --git a/openedx/core/djangoapps/api_admin/models.py b/openedx/core/djangoapps/api_admin/models.py index e304569c8447..e98f5831f939 100644 --- a/openedx/core/djangoapps/api_admin/models.py +++ b/openedx/core/djangoapps/api_admin/models.py @@ -6,7 +6,7 @@ from config_models.models import ConfigurationModel from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site from django.core.mail import send_mail from django.db import models @@ -252,9 +252,9 @@ def __init__(self, *args, **kwargs): self.query = attributes['query'] self.viewers = attributes['viewers'] else: - super(Catalog, self).__init__(*args, **kwargs) + super(Catalog, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments - def save(self, **kwargs): # pylint: disable=unused-argument + def save(self, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, unused-argument return None @property diff --git a/openedx/core/djangoapps/api_admin/tests/test_forms.py b/openedx/core/djangoapps/api_admin/tests/test_forms.py index 8288362b6994..39c79c808192 100644 --- a/openedx/core/djangoapps/api_admin/tests/test_forms.py +++ b/openedx/core/djangoapps/api_admin/tests/test_forms.py @@ -37,7 +37,7 @@ def test_render_value(self): extra_formating = '' if django.VERSION < (2, 1): extra_formating = ' /' - expected_widget_html = '<input type="text" name="{input_field_name}" value="{serialized_value}"{extra_formating}>'.format( + expected_widget_html = '<input type="text" name="{input_field_name}" value="{serialized_value}"{extra_formating}>'.format( # lint-amnesty, pylint: disable=line-too-long input_field_name=input_field_name, serialized_value=dummy_string_value, extra_formating=extra_formating, diff --git a/openedx/core/djangoapps/api_admin/tests/test_models.py b/openedx/core/djangoapps/api_admin/tests/test_models.py index e0c9b631f068..2db6fc8af3d3 100644 --- a/openedx/core/djangoapps/api_admin/tests/test_models.py +++ b/openedx/core/djangoapps/api_admin/tests/test_models.py @@ -22,7 +22,7 @@ class ApiAccessRequestTests(TestCase): def setUp(self): - super(ApiAccessRequestTests, self).setUp() + super(ApiAccessRequestTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.request = ApiAccessRequestFactory(user=self.user) @@ -97,7 +97,7 @@ def test_unicode(self): @skip_unless_lms class ApiAccessRequestSignalTests(TestCase): def setUp(self): - super(ApiAccessRequestSignalTests, self).setUp() + super(ApiAccessRequestSignalTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.api_access_request = ApiAccessRequest(user=self.user, site=SiteFactory()) self.send_new_pending_email_function = 'openedx.core.djangoapps.api_admin.models._send_new_pending_email' diff --git a/openedx/core/djangoapps/api_admin/tests/test_views.py b/openedx/core/djangoapps/api_admin/tests/test_views.py index 2f824d2a743a..b376c554e794 100644 --- a/openedx/core/djangoapps/api_admin/tests/test_views.py +++ b/openedx/core/djangoapps/api_admin/tests/test_views.py @@ -29,7 +29,7 @@ class ApiAdminTest(TestCase): Base class to allow API admin access to tests. """ def setUp(self): - super(ApiAdminTest, self).setUp() + super(ApiAdminTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments ApiAccessConfig(enabled=True).save() @@ -39,7 +39,7 @@ class ApiRequestViewTest(ApiAdminTest): Test the API Request View. """ def setUp(self): - super(ApiRequestViewTest, self).setUp() + super(ApiRequestViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse('api_admin:api-request') password = 'abc123' self.user = UserFactory(password=password) @@ -110,7 +110,7 @@ class ApiRequestStatusViewTest(ApiAdminTest): Tests of the API Status endpoint. """ def setUp(self): - super(ApiRequestStatusViewTest, self).setUp() + super(ApiRequestStatusViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments password = 'abc123' self.user = UserFactory(password=password) self.client.login(username=self.user.username, password=password) @@ -226,7 +226,7 @@ class CatalogTest(ApiAdminTest): Test the catalog API. """ def setUp(self): - super(CatalogTest, self).setUp() + super(CatalogTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments password = 'abc123' self.user = UserFactory(password=password, is_staff=True) self.client.login(username=self.user.username, password=password) @@ -254,7 +254,7 @@ class CatalogSearchViewTest(CatalogTest): Test the catalog search endpoint. """ def setUp(self): - super(CatalogSearchViewTest, self).setUp() + super(CatalogSearchViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse('api_admin:catalog-search') def test_get(self): @@ -279,7 +279,7 @@ class CatalogListViewTest(CatalogTest): Test the catalog list endpoint. """ def setUp(self): - super(CatalogListViewTest, self).setUp() + super(CatalogListViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.catalog_user = UserFactory() self.url = reverse('api_admin:catalog-list', kwargs={'username': self.catalog_user.username}) @@ -331,7 +331,7 @@ class CatalogEditViewTest(CatalogTest): Test edits to the catalog endpoint. """ def setUp(self): - super(CatalogEditViewTest, self).setUp() + super(CatalogEditViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.catalog_user = UserFactory() self.catalog = CatalogFactory(viewers=[self.catalog_user.username]) self.url = reverse('api_admin:catalog-edit', kwargs={'catalog_id': self.catalog.id}) @@ -353,7 +353,7 @@ def test_delete(self): self.assertRedirects(response, reverse('api_admin:catalog-search')) self.assertEqual(httpretty.last_request().method, 'DELETE') self.assertEqual( - httpretty.last_request().path, + httpretty.last_request().path, # lint-amnesty, pylint: disable=no-member '/api/v1/catalogs/{}/'.format(self.catalog.id) ) self.assertEqual(len(httpretty.httpretty.latest_requests), 1) @@ -382,7 +382,7 @@ class CatalogPreviewViewTest(CatalogTest): Test the catalog preview endpoint. """ def setUp(self): - super(CatalogPreviewViewTest, self).setUp() + super(CatalogPreviewViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse('api_admin:catalog-preview') @httpretty.activate diff --git a/openedx/core/djangoapps/api_admin/views.py b/openedx/core/djangoapps/api_admin/views.py index 3e2dbbfdf356..240f70b0f43d 100644 --- a/openedx/core/djangoapps/api_admin/views.py +++ b/openedx/core/djangoapps/api_admin/views.py @@ -33,19 +33,19 @@ class ApiRequestView(CreateView): template_name = 'api_admin/api_access_request_form.html' success_url = reverse_lazy('api_admin:api-status') - def get(self, request): + def get(self, request): # lint-amnesty, pylint: disable=arguments-differ """ If the requesting user has already requested API access, redirect them to the client creation page. """ if ApiAccessRequest.api_access_status(request.user) is not None: return redirect(reverse('api_admin:api-status')) - return super(ApiRequestView, self).get(request) + return super(ApiRequestView, self).get(request) # lint-amnesty, pylint: disable=super-with-arguments def form_valid(self, form): form.instance.user = self.request.user form.instance.site = get_current_site(self.request) - return super(ApiRequestView, self).form_valid(form) + return super(ApiRequestView, self).form_valid(form) # lint-amnesty, pylint: disable=super-with-arguments class ApiRequestStatusView(ApplicationRegistration): @@ -87,7 +87,7 @@ def get(self, request, form=None): # pylint: disable=arguments-differ }) def get_form(self, form_class=None): - form = super(ApiRequestStatusView, self).get_form(form_class) + form = super(ApiRequestStatusView, self).get_form(form_class) # lint-amnesty, pylint: disable=super-with-arguments # Copy the data, since it's an immutable QueryDict. copied_data = form.data.copy() # Now set the fields that were removed earlier. We give them @@ -105,14 +105,14 @@ def get_form(self, form_class=None): def form_valid(self, form): # Delete any existing applications if the user has decided to regenerate their credentials Application.objects.filter(user=self.request.user).delete() - return super(ApiRequestStatusView, self).form_valid(form) + return super(ApiRequestStatusView, self).form_valid(form) # lint-amnesty, pylint: disable=super-with-arguments def form_invalid(self, form): return self.get(self.request, form) @require_api_access - def post(self, request): - return super(ApiRequestStatusView, self).post(request) + def post(self, request): # lint-amnesty, pylint: disable=arguments-differ + return super(ApiRequestStatusView, self).post(request) # lint-amnesty, pylint: disable=super-with-arguments class ApiTosView(TemplateView): diff --git a/openedx/core/djangoapps/auth_exchange/forms.py b/openedx/core/djangoapps/auth_exchange/forms.py index fda8bcc3dbbc..a0c81da4a045 100644 --- a/openedx/core/djangoapps/auth_exchange/forms.py +++ b/openedx/core/djangoapps/auth_exchange/forms.py @@ -3,7 +3,7 @@ """ from django import forms -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.forms import CharField from django.conf import settings from django.utils.encoding import smart_text @@ -86,7 +86,7 @@ class AccessTokenExchangeForm(forms.Form): client_id = CharField(required=False) def __init__(self, request, oauth2_adapter, *args, **kwargs): - super(AccessTokenExchangeForm, self).__init__(*args, **kwargs) + super(AccessTokenExchangeForm, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.request = request self.oauth2_adapter = oauth2_adapter @@ -96,7 +96,7 @@ def _clean_fields(self): instead of validating each field. """ try: - super(AccessTokenExchangeForm, self)._clean_fields() + super(AccessTokenExchangeForm, self)._clean_fields() # lint-amnesty, pylint: disable=super-with-arguments except OAuthValidationError as e: self._errors.update(e.args[0]) @@ -105,7 +105,7 @@ def _clean_form(self): Overriding the default cleaning behaviour for a shallow error dict. """ try: - super(AccessTokenExchangeForm, self)._clean_form() + super(AccessTokenExchangeForm, self)._clean_form() # lint-amnesty, pylint: disable=super-with-arguments except OAuthValidationError as e: self._errors.update(e.args[0]) @@ -164,7 +164,7 @@ def clean(self): try: client = self.oauth2_adapter.get_client(client_id=client_id) except Application.DoesNotExist: - raise OAuthValidationError( + raise OAuthValidationError( # lint-amnesty, pylint: disable=raise-missing-from { "error": "invalid_client", "error_description": u"{} is not a valid client_id".format(client_id), diff --git a/openedx/core/djangoapps/auth_exchange/tests/mixins.py b/openedx/core/djangoapps/auth_exchange/tests/mixins.py index 1ed3ac7d8d30..ef093bec5f4d 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/mixins.py +++ b/openedx/core/djangoapps/auth_exchange/tests/mixins.py @@ -65,4 +65,4 @@ def test_get_method(self): @expectedFailure def test_single_access_token(self): # TODO: Single access tokens not supported yet for DOT (See MA-2122) - super(DOTAdapterMixin, self).test_single_access_token() + super(DOTAdapterMixin, self).test_single_access_token() # lint-amnesty, pylint: disable=super-with-arguments diff --git a/openedx/core/djangoapps/auth_exchange/tests/test_forms.py b/openedx/core/djangoapps/auth_exchange/tests/test_forms.py index b0dd06563d60..ac350fe351d5 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/test_forms.py +++ b/openedx/core/djangoapps/auth_exchange/tests/test_forms.py @@ -13,7 +13,7 @@ from django.test.client import RequestFactory from social_django.models import Partial -from common.djangoapps.third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle +from common.djangoapps.third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle # lint-amnesty, pylint: disable=line-too-long from ..forms import AccessTokenExchangeForm from .mixins import DOTAdapterMixin @@ -25,7 +25,7 @@ class AccessTokenExchangeFormTest(AccessTokenExchangeTestMixin): Mixin that defines test cases for AccessTokenExchangeForm """ def setUp(self): - super(AccessTokenExchangeFormTest, self).setUp() + super(AccessTokenExchangeFormTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request = RequestFactory().post("dummy_url") redirect_uri = 'dummy_redirect_url' SessionMiddleware().process_request(self.request) @@ -34,10 +34,10 @@ def setUp(self): self.request.backend = social_utils.load_backend(self.request.social_strategy, self.BACKEND, redirect_uri) def tearDown(self): - super(AccessTokenExchangeFormTest, self).tearDown() + super(AccessTokenExchangeFormTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments Partial.objects.all().delete() - def _assert_error(self, data, expected_error, expected_error_description): + def _assert_error(self, data, expected_error, expected_error_description): # lint-amnesty, pylint: disable=arguments-differ form = AccessTokenExchangeForm(request=self.request, oauth2_adapter=self.oauth2_adapter, data=data) self.assertEqual( form.errors, @@ -65,7 +65,7 @@ class DOTAccessTokenExchangeFormTestFacebook( Tests for AccessTokenExchangeForm used with Facebook, tested against django-oauth-toolkit (DOT). """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass # This is necessary because cms does not implement third party auth @@ -81,4 +81,4 @@ class DOTAccessTokenExchangeFormTestGoogle( Tests for AccessTokenExchangeForm used with Google, tested against django-oauth-toolkit (DOT). """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/openedx/core/djangoapps/auth_exchange/tests/test_views.py b/openedx/core/djangoapps/auth_exchange/tests/test_views.py index ec6408604f8e..82283fd393bc 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/test_views.py +++ b/openedx/core/djangoapps/auth_exchange/tests/test_views.py @@ -22,7 +22,7 @@ from openedx.core.djangoapps.oauth_dispatch.tests import factories as dot_factories from common.djangoapps.student.tests.factories import UserFactory -from common.djangoapps.third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle +from common.djangoapps.third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle # lint-amnesty, pylint: disable=line-too-long from .mixins import DOTAdapterMixin from .utils import TPA_FEATURE_ENABLED, TPA_FEATURES_KEY, AccessTokenExchangeTestMixin @@ -34,12 +34,12 @@ class AccessTokenExchangeViewTest(AccessTokenExchangeTestMixin): Mixin that defines test cases for AccessTokenExchangeView """ def setUp(self): - super(AccessTokenExchangeViewTest, self).setUp() + super(AccessTokenExchangeViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("exchange_access_token", kwargs={"backend": self.BACKEND}) self.csrf_client = APIClient(enforce_csrf_checks=True) def tearDown(self): - super(AccessTokenExchangeViewTest, self).tearDown() + super(AccessTokenExchangeViewTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments Partial.objects.all().delete() def _assert_error(self, data, expected_error, expected_error_description, error_code=None): @@ -120,7 +120,7 @@ def test_invalid_client(self): Remove when dop has been removed from third party auth (currently underlying code used dop adapter, which is no longer supported by auth_exchange) """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @pytest.mark.skip(reason="this is very entangled with dop use in third_party_auth") def test_missing_fields(self): @@ -128,7 +128,7 @@ def test_missing_fields(self): Remove when dop has been removed from third party auth (currently underlying code used dop adapter, which is no longer supported by auth_exchange) """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def test_disabled_user(self): """ @@ -151,7 +151,7 @@ class DOTAccessTokenExchangeViewTestFacebook( """ Rerun AccessTokenExchangeViewTestFacebook tests against DOT backend """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass # This is necessary because cms does not implement third party auth @@ -167,7 +167,7 @@ class DOTAccessTokenExchangeViewTestGoogle( Tests for AccessTokenExchangeView used with Google using django-oauth-toolkit backend. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @unittest.skipUnless(settings.FEATURES.get("ENABLE_OAUTH2_PROVIDER"), "OAuth2 not enabled") @@ -176,7 +176,7 @@ class TestLoginWithAccessTokenView(TestCase): Tests for LoginWithAccessTokenView """ def setUp(self): - super(TestLoginWithAccessTokenView, self).setUp() + super(TestLoginWithAccessTokenView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.oauth2_client = Application.objects.create(client_type=Application.CLIENT_CONFIDENTIAL) diff --git a/openedx/core/djangoapps/auth_exchange/tests/utils.py b/openedx/core/djangoapps/auth_exchange/tests/utils.py index 3a7148a8222d..09d13950f70c 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/utils.py +++ b/openedx/core/djangoapps/auth_exchange/tests/utils.py @@ -20,7 +20,7 @@ class AccessTokenExchangeTestMixin(ThirdPartyOAuthTestMixin): * _assert_success(data, expected_scopes) """ def setUp(self): - super(AccessTokenExchangeTestMixin, self).setUp() + super(AccessTokenExchangeTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Initialize to minimal data self.data = { @@ -61,11 +61,11 @@ def test_missing_fields(self): for field in ["access_token", "client_id"]: data = dict(self.data) del data[field] - self._assert_error(data, "invalid_request", u"{} is required".format(field)) + self._assert_error(data, "invalid_request", u"{} is required".format(field)) # lint-amnesty, pylint: disable=no-value-for-parameter def test_invalid_client(self): self.data["client_id"] = "nonexistent_client" - self._assert_error( + self._assert_error( # lint-amnesty, pylint: disable=no-value-for-parameter self.data, "invalid_client", "nonexistent_client is not a valid client_id" @@ -74,7 +74,7 @@ def test_invalid_client(self): def test_confidential_client(self): self.data['client_id'] += '_confidential' self.oauth_client = self.create_confidential_client(self.user, self.data['client_id']) - self._assert_error( + self._assert_error( # lint-amnesty, pylint: disable=no-value-for-parameter self.data, "invalid_client", "{}_confidential is not a public client".format(self.client_id), @@ -88,13 +88,13 @@ def test_inactive_user(self): def test_invalid_acess_token(self): self._setup_provider_response(success=False) - self._assert_error(self.data, "invalid_grant", "access_token is not valid") + self._assert_error(self.data, "invalid_grant", "access_token is not valid") # lint-amnesty, pylint: disable=no-value-for-parameter def test_no_linked_user(self): UserSocialAuth.objects.all().delete() Partial.objects.all().delete() self._setup_provider_response(success=True) - self._assert_error(self.data, "invalid_grant", "access_token is not valid") + self._assert_error(self.data, "invalid_grant", "access_token is not valid") # lint-amnesty, pylint: disable=no-value-for-parameter def test_user_automatically_linked_by_email(self): UserSocialAuth.objects.all().delete() @@ -108,4 +108,4 @@ def test_inactive_user_not_automatically_linked(self): self._setup_provider_response(success=True, email=self.user.email) self.user.is_active = False self.user.save() - self._assert_error(self.data, "invalid_grant", "access_token is not valid") + self._assert_error(self.data, "invalid_grant", "access_token is not valid") # lint-amnesty, pylint: disable=no-value-for-parameter diff --git a/openedx/core/djangoapps/auth_exchange/views.py b/openedx/core/djangoapps/auth_exchange/views.py index e8870e88b674..b1fa31f943ee 100644 --- a/openedx/core/djangoapps/auth_exchange/views.py +++ b/openedx/core/djangoapps/auth_exchange/views.py @@ -38,19 +38,19 @@ class AccessTokenExchangeBase(APIView): @method_decorator(csrf_exempt) @method_decorator(social_utils.psa("social:complete")) def dispatch(self, *args, **kwargs): # pylint: disable=arguments-differ - return super(AccessTokenExchangeBase, self).dispatch(*args, **kwargs) + return super(AccessTokenExchangeBase, self).dispatch(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments def get(self, request, _backend): """ Pass through GET requests without the _backend """ - return super(AccessTokenExchangeBase, self).get(request) + return super(AccessTokenExchangeBase, self).get(request) # lint-amnesty, pylint: disable=no-member, super-with-arguments def post(self, request, _backend): """ Handle POST requests to get a first-party access token. """ - form = AccessTokenExchangeForm(request=request, oauth2_adapter=self.oauth2_adapter, data=request.POST) + form = AccessTokenExchangeForm(request=request, oauth2_adapter=self.oauth2_adapter, data=request.POST) # lint-amnesty, pylint: disable=no-member if not form.is_valid(): error_response = self.error_response(form.errors) # pylint: disable=no-member if error_response.status_code == 403: @@ -74,7 +74,7 @@ def exchange_access_token(self, request, user, scope, client): """ edx_access_token = self.create_access_token(request, user, scope, client) - return self.access_token_response(edx_access_token) + return self.access_token_response(edx_access_token) # lint-amnesty, pylint: disable=no-member class DOTAccessTokenExchangeView(AccessTokenExchangeBase, DOTAccessTokenView): diff --git a/openedx/core/djangoapps/bookmarks/__init__.py b/openedx/core/djangoapps/bookmarks/__init__.py index 4879e7774c31..539ec9a834cb 100644 --- a/openedx/core/djangoapps/bookmarks/__init__.py +++ b/openedx/core/djangoapps/bookmarks/__init__.py @@ -1,4 +1,5 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured +# lint-amnesty, pylint: disable=django-not-configured # lint-amnesty, pylint: disable=django-not-configured Bookmarks module. """ diff --git a/openedx/core/djangoapps/bookmarks/api.py b/openedx/core/djangoapps/bookmarks/api.py index f58a5f38fec9..28ffb96b61e8 100644 --- a/openedx/core/djangoapps/bookmarks/api.py +++ b/openedx/core/djangoapps/bookmarks/api.py @@ -19,7 +19,7 @@ class BookmarksLimitReachedError(Exception): """ if try to create new bookmark when max limit of bookmarks already reached """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def get_bookmark(user, usage_key, fields=None): diff --git a/openedx/core/djangoapps/bookmarks/apps.py b/openedx/core/djangoapps/bookmarks/apps.py index 95edce194186..2b3948f78f7f 100644 --- a/openedx/core/djangoapps/bookmarks/apps.py +++ b/openedx/core/djangoapps/bookmarks/apps.py @@ -35,4 +35,4 @@ class BookmarksConfig(AppConfig): def ready(self): # Register the signals handled by bookmarks. - from . import signals + from . import signals # lint-amnesty, pylint: disable=unused-import
0
9748cb80d2f24c89218f358ca2f5ab88ee33396f
https://github.com/top-think/thinkphp/commit/9748cb80d2f24c89218f358ca2f5ab88ee33396f
改进
diff --git a/ThinkPHP/Library/Think/Db/Driver.class.php b/ThinkPHP/Library/Think/Db/Driver.class.php index 1a673991e..a3b128318 100644 --- a/ThinkPHP/Library/Think/Db/Driver.class.php +++ b/ThinkPHP/Library/Think/Db/Driver.class.php @@ -758,29 +758,29 @@ protected function parseOrder($order) return ''; } $array = array(); + if (is_string($order) && '[RAND]' != $order) { + $order = explode(',', $order); + } + if (is_array($order)) { foreach ($order as $key => $val) { if (is_numeric($key)) { - if (false === strpos($val, '(') && false === strpos($val, ';')) { - $array[] = $this->parseKey($val); - } - } elseif (false === strpos($key, ')') && false === strpos($key, '#')) { - $sort = in_array(strtolower($val), array('asc', 'desc')) ? ' ' . $val : ''; + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); + } else { + $sort = $val; + } + + if (preg_match('/^[\w]+$/', $key)) { + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; $array[] = $this->parseKey($key, true) . $sort; } } } elseif ('[RAND]' == $order) { // 随机排序 $array[] = $this->parseRand(); - } else { - foreach (explode(',', $order) as $val) { - if (preg_match('/\s+(ASC|DESC)$/i', rtrim($val), $match, PREG_OFFSET_CAPTURE)) { - $array[] = $this->parseKey(ltrim(substr($val, 0, $match[0][1]))) . ' ' . $match[1][0]; - } elseif (false === strpos($val, '(') && false === strpos($val, ';')) { - $array[] = $this->parseKey($val); - } - } } + $order = implode(',', $array); return !empty($order) ? ' ORDER BY ' . $order : ''; }
1
5a0e04286f3462e3308f2a332eb0f90a66920218
https://github.com/rpm-software-management/libcomps/commit/5a0e04286f3462e3308f2a332eb0f90a66920218
Release 0.1.14
diff --git a/libcomps.spec b/libcomps.spec index bebb5fd..ef9751d 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -13,7 +13,7 @@ %endif Name: libcomps -Version: 0.1.13 +Version: 0.1.14 Release: 1%{?dist} Summary: Comps XML file manipulation library diff --git a/libcomps/version.cmake b/libcomps/version.cmake index d4d27ac..0f9d482 100644 --- a/libcomps/version.cmake +++ b/libcomps/version.cmake @@ -1,5 +1,5 @@ set (libcomps_VERSION_MAJOR 0) set (libcomps_VERSION_MINOR 1) -set (libcomps_VERSION_PATCH 13) +set (libcomps_VERSION_PATCH 14) set (libcomps_RELEASE 1) diff --git a/rel-eng/packages/libcomps b/rel-eng/packages/libcomps index bfba1f7..d2f5aff 100644 --- a/rel-eng/packages/libcomps +++ b/rel-eng/packages/libcomps @@ -1 +1 @@ -0.1.13-1 ./ +0.1.14-1 ./ diff --git a/version.json b/version.json index f6e34b2..21a42b2 100644 --- a/version.json +++ b/version.json @@ -2,5 +2,5 @@ "libcomps_VERSION_MAJOR": 0, "libcomps_RELEASE": 1, "libcomps_VERSION_MINOR": 1, - "libcomps_VERSION_PATCH": 13 + "libcomps_VERSION_PATCH": 14 }
0
25a2911eb68fe5ab91c968bc6a2457f8d8af1031
https://github.com/fontforge/fontforge/commit/25a2911eb68fe5ab91c968bc6a2457f8d8af1031
striptcc: Calculating checksum with filecheck() requires read+write access. (#4549) With write-only access, the checksumming process would always fail causing incorrect checkSumAdjustment being written to the .ttf files produced.
diff --git a/contrib/fonttools/stripttc.c b/contrib/fonttools/stripttc.c index 8dbf7d1863..340e89be46 100644 --- a/contrib/fonttools/stripttc.c +++ b/contrib/fonttools/stripttc.c @@ -81,7 +81,7 @@ static int handlefont(char *filename,int which,FILE *ttc,int offset) { pt = outfile + strlen(outfile); sprintf( pt, "_%02d.ttf", which ); - ttf = fopen( outfile,"wb"); + ttf = fopen( outfile,"w+b"); if ( ttf==NULL ) { fprintf( stderr, "Failed to open %s for output.\n", outfile ); return( -3 );
0
352aa5170d3b5b06e450b186d5ddbf63c84b370f
https://github.com/haberman/gazelle/commit/352aa5170d3b5b06e450b186d5ddbf63c84b370f
Add some generated files to .gitignore.
diff --git a/.gitignore b/.gitignore index a35238d..647cf08 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,10 @@ *.so *.a *.gzc +gzlc lua_path +luac.out +utilities/bitcode_dump +utilities/gzlparse +utilities/srlua +utilities/srlua-glue
0
f8642a1986a44e661cf526505ccca26c37fd10d7
https://github.com/shadow-maint/shadow/commit/f8642a1986a44e661cf526505ccca26c37fd10d7
Merge pull request #288 from whzhe51/br_whzhe xfree: move xfree() function to xmalloc.c
diff --git a/lib/prototypes.h b/lib/prototypes.h index 53d991fea..ac9ad274a 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -448,6 +448,7 @@ extern bool valid (const char *, const struct passwd *); extern /*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/char *xmalloc (size_t size) /*@ensures MaxSet(result) == (size - 1); @*/; extern /*@maynotreturn@*/ /*@only@*//*@notnull@*/char *xstrdup (const char *); +extern void xfree(void *ap); /* xgetpwnam.c */ extern /*@null@*/ /*@only@*/struct passwd *xgetpwnam (const char *); diff --git a/libmisc/xmalloc.c b/libmisc/xmalloc.c index 41a3343c9..0c55d5b4e 100644 --- a/libmisc/xmalloc.c +++ b/libmisc/xmalloc.c @@ -66,3 +66,10 @@ { return strcpy (xmalloc (strlen (str) + 1), str); } + +void xfree(void *ap) +{ + if (ap) { + free(ap); + } +} diff --git a/src/gpasswd.c b/src/gpasswd.c index a25bf3e5d..9331d30c1 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -123,12 +123,6 @@ static void log_gpasswd_success (const char *suffix); static void log_gpasswd_success_system (/*@null@*/unused void *arg); static void log_gpasswd_success_group (/*@null@*/unused void *arg); -static void xfree(void* p) { - if (p) { - free(p); - } -} - /* * usage - display usage message */
0
69119019757eb9cf770904e9c83e99595892c859
https://github.com/brookinsconsulting/bccie/commit/69119019757eb9cf770904e9c83e99595892c859
Merge pull request #20 from lpmi-13/typofix Updated: Merge pull request #20 fix simple typo
diff --git a/README.md b/README.md index c99b0dc..e3e82d4 100755 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Troubleshooting * Read the FAQ -Some problems are more common than others. The most common ones are listed in the the [doc/FAQ.md](doc/FAQ.md). +Some problems are more common than others. The most common ones are listed in the [doc/FAQ.md](doc/FAQ.md). * Support
0
a26aabfe1c152da45cba2e7236effb1808ef04ae
https://github.com/jenkinsci/ansible-plugin/commit/a26aabfe1c152da45cba2e7236effb1808ef04ae
[maven-release-plugin] prepare release ansible-0.6.2
diff --git a/pom.xml b/pom.xml index 8b517e6..c81723f 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ <groupId>org.jenkins-ci.plugins</groupId> <artifactId>ansible</artifactId> - <version>0.7-SNAPSHOT</version> + <version>0.6.2</version> <packaging>hpi</packaging> <name>Jenkins Ansible plugin</name> <description>Ansible support in Jenkins</description> @@ -34,7 +34,7 @@ <connection>scm:git:ssh://github.com/jenkinsci/ansible-plugin.git</connection> <developerConnection>scm:git:ssh://[email protected]/jenkinsci/ansible-plugin.git</developerConnection> <url>https://github.com/jcsirot/ansible-plugin</url> - <tag>HEAD</tag> + <tag>ansible-0.6.2</tag> </scm> <repositories>
0
0ceca22be5013b41be04c621aca3cdc125066dbc
https://github.com/libressl-portable/openbsd/commit/0ceca22be5013b41be04c621aca3cdc125066dbc
Move private key setup to a helper function with proper error checking. Only install the hash on the key if fake key is used, and do it for EC keys too. ok tb@ jsing@
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c index 5e02b5a427..f8f18b9fee 100644 --- a/src/lib/libtls/tls.c +++ b/src/lib/libtls/tls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls.c,v 1.87 2021/01/21 22:02:17 eric Exp $ */ +/* $OpenBSD: tls.c,v 1.88 2021/01/26 12:51:22 eric Exp $ */ /* * Copyright (c) 2014 Joel Sing <[email protected]> * @@ -384,6 +384,50 @@ tls_keypair_to_pkey(struct tls *ctx, struct tls_keypair *keypair, EVP_PKEY **pke return (ret); } +static int +tls_keypair_setup_pkey(struct tls *ctx, struct tls_keypair *keypair, EVP_PKEY *pkey) +{ + RSA *rsa = NULL; + EC_KEY *eckey = NULL; + int ret = -1; + + /* Only install the pubkey hash if fake private keys are used. */ + if (!ctx->config->skip_private_key_check) + return (0); + + if (keypair->pubkey_hash == NULL) { + tls_set_errorx(ctx, "public key hash not set"); + goto err; + } + + switch (EVP_PKEY_id(pkey)) { + case EVP_PKEY_RSA: + if ((rsa = EVP_PKEY_get1_RSA(pkey)) == NULL || + RSA_set_ex_data(rsa, 0, keypair->pubkey_hash) == 0) { + tls_set_errorx(ctx, "failed to setup RSA key"); + goto err; + } + break; + case EVP_PKEY_EC: + if ((eckey = EVP_PKEY_get1_EC_KEY(pkey)) == NULL || + ECDSA_set_ex_data(eckey, 0, keypair->pubkey_hash) == 0) { + tls_set_errorx(ctx, "failed to setup EC key"); + goto err; + } + break; + default: + tls_set_errorx(ctx, "incorrect key type"); + goto err; + } + + ret = 0; + + err: + RSA_free(rsa); + EC_KEY_free(eckey); + return (ret); +} + int tls_configure_ssl_keypair(struct tls *ctx, SSL_CTX *ssl_ctx, struct tls_keypair *keypair, int required) @@ -411,15 +455,8 @@ tls_configure_ssl_keypair(struct tls *ctx, SSL_CTX *ssl_ctx, if (tls_keypair_to_pkey(ctx, keypair, &pkey) == -1) goto err; if (pkey != NULL) { - if (keypair->pubkey_hash != NULL) { - RSA *rsa; - /* XXX only RSA for now for relayd privsep */ - if ((rsa = EVP_PKEY_get1_RSA(pkey)) != NULL) { - RSA_set_ex_data(rsa, 0, keypair->pubkey_hash); - RSA_free(rsa); - } - } - + if (tls_keypair_setup_pkey(ctx, keypair, pkey) == -1) + goto err; if (SSL_CTX_use_PrivateKey(ssl_ctx, pkey) != 1) { tls_set_errorx(ctx, "failed to load private key"); goto err;
0
fa2a4b58b4808605d36c7b95b84d3adc49f854aa
https://github.com/viabtc/viabtc_exchange_server/commit/fa2a4b58b4808605d36c7b95b84d3adc49f854aa
Update README.md
diff --git a/README.md b/README.md index 6e429ea8..2080ea35 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This project is the server part in this picture. * utils: some basic library. Include log, config parse, some data structure, http/websocket/rpc server implementation. -**Models** +**modules** * matchengine: the most important part, it reord user balance, execute user order. It is a in memory database, save oper log in MySQL, redo the oper log when start. It also write user history into MySQL, push balance and order and deal message to kafka.
0
402f3d967c0a905ec5b9ca9c240783d3f2c15724
https://github.com/Microsoft/ChakraCore/commit/402f3d967c0a905ec5b9ca9c240783d3f2c15724
[CVE-2017-0028] Fix binding of 'async' identifier in the presence of async arrow function.
diff --git a/lib/Parser/Parse.cpp b/lib/Parser/Parse.cpp index 5db98640ef8..683a8fdf433 100644 --- a/lib/Parser/Parse.cpp +++ b/lib/Parser/Parse.cpp @@ -2863,6 +2863,7 @@ ParseNodePtr Parser::ParseTerm(BOOL fAllowCall, _Inout_opt_ charcount_t *plastRParen /*= nullptr*/) { ParseNodePtr pnode = nullptr; + PidRefStack *savedTopAsyncRef = nullptr; charcount_t ichMin = 0; size_t iecpMin = 0; size_t iuMin; @@ -2915,6 +2916,13 @@ ParseNodePtr Parser::ParseTerm(BOOL fAllowCall, isLambdaExpr = true; goto LFunction; } + else if (m_token.tk == tkLParen) + { + // This is potentially an async arrow function. Save the state of the async references + // in case it needs to be restored. (Note that the case of a single parameter with no ()'s + // is detected upstream and need not be handled here.) + savedTopAsyncRef = pid->GetTopRef(); + } } // Don't push a reference if this is a single lambda parameter, because we'll reparse with @@ -3269,6 +3277,18 @@ LFunction : pnode = ParsePostfixOperators<buildAST>(pnode, fAllowCall, fInNew, isAsyncExpr, &fCanAssign, &term, pfIsDotOrIndex); + if (savedTopAsyncRef != nullptr && + this->m_token.tk == tkDArrow) + { + // This is an async arrow function; we're going to back up and reparse it. + // Make sure we don't leave behind a bogus reference to the 'async' identifier. + for (IdentPtr pid = wellKnownPropertyPids.async; pid->GetTopRef() != savedTopAsyncRef;) + { + Assert(pid->GetTopRef() != nullptr); + pid->RemovePrevPidRef(nullptr); + } + } + // Pass back identifier if requested if (pToken && term.tk == tkID) { diff --git a/test/es6/lambda-params-shadow.js b/test/es6/lambda-params-shadow.js index 1e45ab40bf3..69c07a584e5 100644 --- a/test/es6/lambda-params-shadow.js +++ b/test/es6/lambda-params-shadow.js @@ -18,7 +18,14 @@ class B extends A { } } let b = new B(); -if (count !== 3) { +class async extends A { + constructor() { + super(); + let Q = async A => { A }; + } +} +let a = new async(); +if (count !== 4) { WScript.Echo('fail'); }
1
3a8016d31f517775d226aa8b902480f4a3a148a9#comments
https://github.com/Bitmessage/PyBitmessage/commit/3a8016d31f517775d226aa8b902480f4a3a148a9#comments
Fix message encoding bug - prevent loading invalid message types
diff --git a/src/messagetypes/__init__.py b/src/messagetypes/__init__.py index c3911dfdee..d929101326 100644 --- a/src/messagetypes/__init__.py +++ b/src/messagetypes/__init__.py @@ -12,9 +12,10 @@ def encode(self): def constructObject(data): try: - classBase = eval(data[""] + "." + data[""].title()) - except NameError: - logger.error("Don't know how to handle message type: \"%s\"", data[""]) + m = import_module("messagetypes." + data[""]) + classBase = getattr(m, data[""].title()) + except (NameError, ImportError): + logger.error("Don't know how to handle message type: \"%s\"", data[""], exc_info=True) return None try: returnObj = classBase()
1
98ae2239b7018d41503dd84a9e6a504ebce18614
https://github.com/zblogcn/zblogphp/commit/98ae2239b7018d41503dd84a9e6a504ebce18614
ApiGetRequestFilter 去掉 limit 和 offset
diff --git a/zb_system/function/c_system_api.php b/zb_system/function/c_system_api.php index 088871f2..c7676293 100644 --- a/zb_system/function/c_system_api.php +++ b/zb_system/function/c_system_api.php @@ -324,8 +324,6 @@ function ApiGetRequestFilter($limitDefault = null, $sortableColumns = array()) ); $sortBy = strtolower((string) GetVars('sortby')); $order = strtoupper((string) GetVars('order')); - $limit = (int) GetVars('limit'); - $offset = (int) GetVars('offset'); $pageNow = (int) GetVars('page'); $perPage = (int) GetVars('perpage');
0
62002348ec80269379334a4deb5373075c0e43ac
https://github.com/hibernate/hibernate-validator/commit/62002348ec80269379334a4deb5373075c0e43ac
HV-1815 Fix DecimalMax and DecimalMin in zh_CN translation
diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_zh_CN.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_zh_CN.properties index f7c2aac9a..386abccee 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_zh_CN.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_zh_CN.properties @@ -1,7 +1,7 @@ jakarta.validation.constraints.AssertFalse.message = \u53ea\u80fd\u4e3afalse jakarta.validation.constraints.AssertTrue.message = \u53ea\u80fd\u4e3atrue -jakarta.validation.constraints.DecimalMax.message = \u5fc5\u987b\u5c0f\u4e8e\u6216\u7b49\u4e8e{value} -jakarta.validation.constraints.DecimalMin.message = \u5fc5\u987b\u5927\u4e8e\u6216\u7b49\u4e8e{value} +jakarta.validation.constraints.DecimalMax.message = \u5FC5\u987B\u5C0F\u4E8E${inclusive == true ? '\u6216\u7B49\u4E8E' : ''}{value} +jakarta.validation.constraints.DecimalMin.message = \u5FC5\u987B\u5927\u4E8E${inclusive == true ? '\u6216\u7B49\u4E8E' : ''}{value} jakarta.validation.constraints.Digits.message = \u6570\u5b57\u7684\u503c\u8d85\u51fa\u4e86\u5141\u8bb8\u8303\u56f4(\u53ea\u5141\u8bb8\u5728{integer}\u4f4d\u6574\u6570\u548c{fraction}\u4f4d\u5c0f\u6570\u8303\u56f4\u5185) jakarta.validation.constraints.Email.message = \u4e0d\u662f\u4e00\u4e2a\u5408\u6cd5\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740 jakarta.validation.constraints.Future.message = \u9700\u8981\u662f\u4e00\u4e2a\u5c06\u6765\u7684\u65f6\u95f4
0
1f0dfe5a42911b6880a1445f13f6d615ddb55387
https://github.com/mdadams/jasper/commit/1f0dfe5a42911b6880a1445f13f6d615ddb55387
Fixed an integer overflow problem in the JPC codec that later resulted in the use of uninitialized data.
diff --git a/src/libjasper/jpc/jpc_t2cod.c b/src/libjasper/jpc/jpc_t2cod.c index 08315dda..174442a1 100644 --- a/src/libjasper/jpc/jpc_t2cod.c +++ b/src/libjasper/jpc/jpc_t2cod.c @@ -432,18 +432,18 @@ static int jpc_pi_nextcprl(register jpc_pi_t *pi) &pi->picomps[pi->compno]; pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++pi->compno, ++pi->picomp) { pirlvl = pi->picomp->pirlvls; - pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn + - pi->picomp->numrlvls - 1)); - pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn + - pi->picomp->numrlvls - 1)); + pi->xstep = pi->picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) << + (pirlvl->prcwidthexpn + pi->picomp->numrlvls - 1)); + pi->ystep = pi->picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) << + (pirlvl->prcheightexpn + pi->picomp->numrlvls - 1)); for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1]; rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) { - pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 << - (pirlvl->prcwidthexpn + pi->picomp->numrlvls - - rlvlno - 1))); - pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 << - (pirlvl->prcheightexpn + pi->picomp->numrlvls - - rlvlno - 1))); + pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * + (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcwidthexpn + + pi->picomp->numrlvls - rlvlno - 1))); + pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * + (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcheightexpn + + pi->picomp->numrlvls - rlvlno - 1))); } for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += pi->ystep - (pi->y % pi->ystep)) { diff --git a/src/libjasper/jpc/jpc_t2cod.h b/src/libjasper/jpc/jpc_t2cod.h index 0a176c96..690e0310 100644 --- a/src/libjasper/jpc/jpc_t2cod.h +++ b/src/libjasper/jpc/jpc_t2cod.h @@ -129,10 +129,10 @@ typedef struct { jpc_pirlvl_t *pirlvls; /* The horizontal sampling period. */ - int hsamp; + uint_fast32_t hsamp; /* The vertical sampling period. */ - int vsamp; + uint_fast32_t vsamp; } jpc_picomp_t; @@ -171,32 +171,32 @@ typedef struct { int lyrno; /* The x-coordinate of the current position. */ - int x; + uint_fast32_t x; /* The y-coordinate of the current position. */ - int y; + uint_fast32_t y; /* The horizontal step size. */ - int xstep; + uint_fast32_t xstep; /* The vertical step size. */ - int ystep; + uint_fast32_t ystep; /* The x-coordinate of the top-left corner of the tile on the reference grid. */ - int xstart; + uint_fast32_t xstart; /* The y-coordinate of the top-left corner of the tile on the reference grid. */ - int ystart; + uint_fast32_t ystart; /* The x-coordinate of the bottom-right corner of the tile on the reference grid (plus one). */ - int xend; + uint_fast32_t xend; /* The y-coordinate of the bottom-right corner of the tile on the reference grid (plus one). */ - int yend; + uint_fast32_t yend; /* The current progression change. */ jpc_pchg_t *pchg;
1
194f592e205990ea8fce72b6c571c14350aca716
https://github.com/LibRaw/LibRaw-demosaic-pack-GPL2/commit/194f592e205990ea8fce72b6c571c14350aca716
Fixed possible foveon buffer overrun (Secunia SA750000)
diff --git a/dcraw_foveon.c b/dcraw_foveon.c index d8b7005..bdde89d 100644 --- a/dcraw_foveon.c +++ b/dcraw_foveon.c @@ -319,7 +319,7 @@ void CLASS foveon_huff (ushort *huff) void CLASS foveon_dp_load_raw() { unsigned c, roff[4], row, col, diff; - ushort huff[512], vpred[2][2], hpred[2]; + ushort huff[1024], vpred[2][2], hpred[2]; fseek (ifp, 8, SEEK_CUR); foveon_huff (huff); @@ -346,12 +346,16 @@ void CLASS foveon_dp_load_raw() void CLASS foveon_load_camf() { unsigned type, wide, high, i, j, row, col, diff; - ushort huff[258], vpred[2][2] = {{512,512},{512,512}}, hpred[2]; + ushort huff[1024], vpred[2][2] = {{512,512},{512,512}}, hpred[2]; fseek (ifp, meta_offset, SEEK_SET); type = get4(); get4(); get4(); wide = get4(); high = get4(); +#ifdef LIBRAW_LIBRARY_BUILD + if(wide>32767 || high > 32767 || wide*high > 20000000) + throw LIBRAW_EXCEPTION_IO_CORRUPT; +#endif if (type == 2) { fread (meta_data, 1, meta_length, ifp); for (i=0; i < meta_length; i++) {
1
5876bd2e5ac546404a98563db9039283dcd0e2a7
https://github.com/spring-projects/spring-data-commons/commit/5876bd2e5ac546404a98563db9039283dcd0e2a7
DATACMNS-1762 - Consider reactive types as wrappers during method introspection. We now perform type unwrapping and introspection for reactive types for method return types and method arguments after decoupling QueryExecutionConverters.supports(…) from ReactiveWrapperConverters.
diff --git a/src/main/java/org/springframework/data/repository/core/support/AbstractRepositoryMetadata.java b/src/main/java/org/springframework/data/repository/core/support/AbstractRepositoryMetadata.java index a02d4c7abb..e79af5b61a 100644 --- a/src/main/java/org/springframework/data/repository/core/support/AbstractRepositoryMetadata.java +++ b/src/main/java/org/springframework/data/repository/core/support/AbstractRepositoryMetadata.java @@ -113,7 +113,8 @@ public static RepositoryMetadata getMetadata(Class<?> repositoryInterface) { return ReactiveWrapperConverters.unwrapWrapperTypes(returnType).getType(); } - return QueryExecutionConverters.unwrapWrapperTypes(returnType).getType(); + return ReactiveWrapperConverters.unwrapWrapperTypes(QueryExecutionConverters.unwrapWrapperTypes(returnType)) + .getType(); } /* diff --git a/src/main/java/org/springframework/data/repository/query/Parameter.java b/src/main/java/org/springframework/data/repository/query/Parameter.java index 04c21ba9fc..faca4ba02a 100644 --- a/src/main/java/org/springframework/data/repository/query/Parameter.java +++ b/src/main/java/org/springframework/data/repository/query/Parameter.java @@ -30,6 +30,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.repository.util.ClassUtils; import org.springframework.data.repository.util.QueryExecutionConverters; +import org.springframework.data.repository.util.ReactiveWrapperConverters; import org.springframework.data.util.ClassTypeInformation; import org.springframework.data.util.Lazy; import org.springframework.data.util.TypeInformation; @@ -228,7 +229,8 @@ private static boolean isDynamicProjectionParameter(MethodParameter parameter) { TypeInformation<?> bound = parameterTypes.getTypeArguments().get(0); TypeInformation<Object> returnType = ClassTypeInformation.fromReturnTypeOf(method); - return bound.equals(QueryExecutionConverters.unwrapWrapperTypes(returnType)); + return bound + .equals(ReactiveWrapperConverters.unwrapWrapperTypes(QueryExecutionConverters.unwrapWrapperTypes(returnType))); } /** @@ -239,7 +241,8 @@ private static boolean isDynamicProjectionParameter(MethodParameter parameter) { * @see QueryExecutionConverters */ private static boolean isWrapped(MethodParameter parameter) { - return QueryExecutionConverters.supports(parameter.getParameterType()); + return QueryExecutionConverters.supports(parameter.getParameterType()) + || ReactiveWrapperConverters.supports(parameter.getParameterType()); } /**
0
27cb4f5d3fff72d70b8e1c2576d5b00d4f63f858
https://github.com/atheme/atheme/commit/27cb4f5d3fff72d70b8e1c2576d5b00d4f63f858
Merge pull request #732 from jesopo/ctcp-case-insensitive noopcanon -> strcasecanon; case insensitive CTCP
diff --git a/libathemecore/ctcp-common.c b/libathemecore/ctcp-common.c index b44a27435c..8f74731e17 100644 --- a/libathemecore/ctcp-common.c +++ b/libathemecore/ctcp-common.c @@ -67,7 +67,7 @@ ctcp_about_handler(struct sourceinfo *si, char *cmd, char *args) void common_ctcp_init(void) { - ctcptree = mowgli_patricia_create(noopcanon); + ctcptree = mowgli_patricia_create(strcasecanon); mowgli_patricia_add(ctcptree, "\001PING", ctcp_ping_handler); mowgli_patricia_add(ctcptree, "\001VERSION\001", ctcp_version_handler);
0
7eb0598927bfb9fbffd0c6e1182985e7b0095344
https://github.com/go-ldap/ldap/commit/7eb0598927bfb9fbffd0c6e1182985e7b0095344
Fix regression with %w verb (#278) The %w fmt verb for errors isn't valid for older versions of Go.
diff --git a/search.go b/search.go index 88a1def..4fcc794 100644 --- a/search.go +++ b/search.go @@ -397,7 +397,7 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { for _, child := range packet.Children[2].Children { decodedChild, err := DecodeControl(child) if err != nil { - return result, fmt.Errorf("failed to decode child control: %w", err) + return result, fmt.Errorf("failed to decode child control: %s", err) } result.Controls = append(result.Controls, decodedChild) } diff --git a/v3/search.go b/v3/search.go index 88a1def..4fcc794 100644 --- a/v3/search.go +++ b/v3/search.go @@ -397,7 +397,7 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { for _, child := range packet.Children[2].Children { decodedChild, err := DecodeControl(child) if err != nil { - return result, fmt.Errorf("failed to decode child control: %w", err) + return result, fmt.Errorf("failed to decode child control: %s", err) } result.Controls = append(result.Controls, decodedChild) }
0
34959c4b0c1af43144ea62f3a89283c523c3c1de
https://github.com/h2o/h2o/commit/34959c4b0c1af43144ea62f3a89283c523c3c1de
Merge pull request #936 with tweaks couple of resource leaks fixes upon startup failure
diff --git a/lib/common/socket/evloop.c.h b/lib/common/socket/evloop.c.h index 26c86f98c1..05d4ac20f6 100644 --- a/lib/common/socket/evloop.c.h +++ b/lib/common/socket/evloop.c.h @@ -285,7 +285,7 @@ void do_write(h2o_socket_t *_sock, h2o_iovec_t *_bufs, size_t bufcnt, h2o_socket sock->_wreq.bufs = sock->_wreq.smallbufs; } else { sock->_wreq.bufs = h2o_mem_alloc(sizeof(h2o_iovec_t) * bufcnt); - sock->_wreq.alloced_ptr = sock->_wreq.bufs = sock->_wreq.bufs; + sock->_wreq.alloced_ptr = sock->_wreq.bufs; } memcpy(sock->_wreq.bufs, bufs, sizeof(h2o_iovec_t) * bufcnt); sock->_wreq.cnt = bufcnt; diff --git a/lib/core/configurator.c b/lib/core/configurator.c index 3a003522df..88c91932ce 100644 --- a/lib/core/configurator.c +++ b/lib/core/configurator.c @@ -301,6 +301,7 @@ static int on_config_hosts(h2o_configurator_command_t *cmd, h2o_configurator_con h2o_configurator_context_t *host_ctx = create_context(ctx, 0); if ((host_ctx->hostconf = h2o_config_register_host(host_ctx->globalconf, hostname, port)) == NULL) { h2o_configurator_errprintf(cmd, key, "duplicate host entry"); + destroy_context(host_ctx); return -1; } host_ctx->mimemap = &host_ctx->hostconf->mimemap; diff --git a/src/main.c b/src/main.c index f2d4cfb685..c8bb7e035c 100644 --- a/src/main.c +++ b/src/main.c @@ -715,7 +715,7 @@ static int find_listener_from_server_starter(struct sockaddr *addr) static int open_unix_listener(h2o_configurator_command_t *cmd, yoml_t *node, struct sockaddr_un *sa) { struct stat st; - int fd; + int fd = -1; struct passwd *owner = NULL, pwbuf; char pwbuf_buf[65536]; unsigned mode = UINT_MAX; @@ -725,17 +725,17 @@ static int open_unix_listener(h2o_configurator_command_t *cmd, yoml_t *node, str if ((t = yoml_get(node, "owner")) != NULL) { if (t->type != YOML_TYPE_SCALAR) { h2o_configurator_errprintf(cmd, t, "`owner` is not a scalar"); - return -1; + goto ErrorExit; } if (getpwnam_r(t->data.scalar, &pwbuf, pwbuf_buf, sizeof(pwbuf_buf), &owner) != 0 || owner == NULL) { h2o_configurator_errprintf(cmd, t, "failed to obtain uid of user:%s: %s", t->data.scalar, strerror(errno)); - return -1; + goto ErrorExit; } } if ((t = yoml_get(node, "permission")) != NULL) { if (t->type != YOML_TYPE_SCALAR || sscanf(t->data.scalar, "%o", &mode) != 1) { h2o_configurator_errprintf(cmd, t, "`permission` must be an octal number"); - return -1; + goto ErrorExit; } } @@ -745,16 +745,14 @@ static int open_unix_listener(h2o_configurator_command_t *cmd, yoml_t *node, str unlink(sa->sun_path); } else { h2o_configurator_errprintf(cmd, node, "path:%s already exists and is not an unix socket.", sa->sun_path); - return -1; + goto ErrorExit; } } /* add new listener */ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1 || bind(fd, (void *)sa, sizeof(*sa)) != 0 || listen(fd, H2O_SOMAXCONN) != 0) { - if (fd != -1) - close(fd); h2o_configurator_errprintf(NULL, node, "failed to listen to socket:%s: %s", sa->sun_path, strerror(errno)); - return -1; + goto ErrorExit; } set_cloexec(fd); @@ -762,14 +760,19 @@ static int open_unix_listener(h2o_configurator_command_t *cmd, yoml_t *node, str if (owner != NULL && chown(sa->sun_path, owner->pw_uid, owner->pw_gid) != 0) { h2o_configurator_errprintf(NULL, node, "failed to chown socket:%s to %s: %s", sa->sun_path, owner->pw_name, strerror(errno)); - return -1; + goto ErrorExit; } if (mode != UINT_MAX && chmod(sa->sun_path, mode) != 0) { h2o_configurator_errprintf(NULL, node, "failed to chmod socket:%s to %o: %s", sa->sun_path, mode, strerror(errno)); - return -1; + goto ErrorExit; } return fd; + +ErrorExit: + if (fd != -1) + close(fd); + return -1; } static int open_tcp_listener(h2o_configurator_command_t *cmd, yoml_t *node, const char *hostname, const char *servname, int domain, @@ -953,12 +956,15 @@ static int on_config_listen(h2o_configurator_command_t *cmd, h2o_configurator_co if ((fd = find_listener_from_server_starter(ai->ai_addr)) == -1) { h2o_configurator_errprintf(cmd, node, "tcp socket:%s:%s is not being bound to the server\n", hostname, servname); + freeaddrinfo(res); return -1; } } else { if ((fd = open_tcp_listener(cmd, node, hostname, servname, ai->ai_family, ai->ai_socktype, ai->ai_protocol, - ai->ai_addr, ai->ai_addrlen)) == -1) + ai->ai_addr, ai->ai_addrlen)) == -1) { + freeaddrinfo(res); return -1; + } } break; default: @@ -967,10 +973,13 @@ static int on_config_listen(h2o_configurator_command_t *cmd, h2o_configurator_co listener = add_listener(fd, ai->ai_addr, ai->ai_addrlen, ctx->hostconf == NULL, proxy_protocol); listener_is_new = 1; } else if (listener->proxy_protocol != proxy_protocol) { + freeaddrinfo(res); goto ProxyConflict; } - if (listener_setup_ssl(cmd, ctx, node, ssl_node, listener, listener_is_new) != 0) + if (listener_setup_ssl(cmd, ctx, node, ssl_node, listener, listener_is_new) != 0) { + freeaddrinfo(res); return -1; + } if (listener->hosts != NULL && ctx->hostconf != NULL) h2o_append_to_null_terminated_list((void *)&listener->hosts, ctx->hostconf); }
1
bf10d72f9cf19425d75f80760281a9dc491220a6
https://github.com/yarolig/didiwiki/commit/bf10d72f9cf19425d75f80760281a9dc491220a6
Added OH link to website
diff --git a/ChangeLog b/ChangeLog index c141837..0d06a49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-12-12 mallum <[email protected]> + + * website/index.htm: + Add Openedhand Link + 2004-11-14 mallum <[email protected]> * src/http.c: (http_server): diff --git a/website/index.htm b/website/index.htm index e16d073..c73277a 100644 --- a/website/index.htm +++ b/website/index.htm @@ -86,6 +86,9 @@ <h2>Mailing List.</h2> <h2>Links.</h2> <p> +<a href="http://o-hand.com">OpenedHand</a>, my company. +</p> +<p> <a href="http://www.gnomefiles.org/app.php?soft_id=404">WebNotes</a> is a Gnome frontend to didwiki. </p> <p>
0
425ed6ee14c4d4cee62200ed0dd946e7c052ab2d
https://github.com/TheHive-Project/Cortex/commit/425ed6ee14c4d4cee62200ed0dd946e7c052ab2d
#264 Lower case user login on oauth
diff --git a/app/org/thp/cortex/services/mappers/GroupUserMapper.scala b/app/org/thp/cortex/services/mappers/GroupUserMapper.scala index 7af37d489..5768d5b30 100644 --- a/app/org/thp/cortex/services/mappers/GroupUserMapper.scala +++ b/app/org/thp/cortex/services/mappers/GroupUserMapper.scala @@ -55,7 +55,7 @@ class GroupUserMapper( .flatMap(o => (jsValue \ o).asOpt[String]) .orElse(defaultOrganization) .fold[JsResult[String]](JsError())(o => JsSuccess(o)) - } yield Fields(Json.obj("login" -> login, "name" -> name, "roles" -> roles, "organization" -> organization)) + } yield Fields(Json.obj("login" -> login.toLowerCase, "name" -> name, "roles" -> roles, "organization" -> organization)) fields match { case JsSuccess(f, _) => Future.successful(f) case JsError(errors) => Future.failed(AuthenticationError(s"User info fails: ${errors.map(_._1).mkString}")) diff --git a/app/org/thp/cortex/services/mappers/SimpleUserMapper.scala b/app/org/thp/cortex/services/mappers/SimpleUserMapper.scala index 9e1665e8a..0a317f414 100644 --- a/app/org/thp/cortex/services/mappers/SimpleUserMapper.scala +++ b/app/org/thp/cortex/services/mappers/SimpleUserMapper.scala @@ -42,7 +42,7 @@ class SimpleUserMapper( .flatMap(o => (jsValue \ o).asOpt[String]) .orElse(defaultOrganization) .fold[JsResult[String]](JsError())(o => JsSuccess(o)) - } yield Fields(Json.obj("login" -> login, "name" -> name, "roles" -> roles, "organization" -> organization)) + } yield Fields(Json.obj("login" -> login.toLowerCase, "name" -> name, "roles" -> roles, "organization" -> organization)) fields match { case JsSuccess(f, _) => Future.successful(f) case JsError(errors) => Future.failed(AuthenticationError(s"User info fails: ${errors.map(_._1).mkString}"))
0
3215fe50dd42c83a7a454dd36486843fe36eae4
https://github.com/apache/camel/commit/3215fe50dd42c83a7a454dd36486843fe36eae4
CAMEL-6748: Optimize File Producers by Skipping Header Evaluation. Thansk to James Carman for the patch. Conflicts: camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java index 27f68c8e80d6..f366e0f5a3c9 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java @@ -256,23 +256,25 @@ public void writeFile(Exchange exchange, String fileName) throws GenericFileOper public String createFileName(Exchange exchange) { String answer; - String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class); - String consumed = exchange.getIn().getHeader(Exchange.FILE_NAME_CONSUMED, String.class); + Object value = exchange.getIn().getHeader(Exchange.FILE_NAME); + + if (value != null && value instanceof String && StringHelper.hasStartToken((String) value, "simple")) { + log.warn("Simple expression: {} detected in header: {} of type String. This feature has been removed (see CAMEL-6748).", value, Exchange.FILE_NAME); + } // expression support Expression expression = endpoint.getFileName(); - if (name != null && !name.equals(consumed)) { - // the header name can be an expression too, that should override - // whatever configured on the endpoint - if (StringHelper.hasStartToken(name, "simple")) { - log.trace("{} contains a Simple expression: {}", Exchange.FILE_NAME, name); - Language language = getEndpoint().getCamelContext().resolveLanguage("file"); - expression = language.createExpression(name); - } + if (value != null && value instanceof Expression) { + expression = (Expression) value; } + + // evaluate the name as a String from the value + String name; if (expression != null) { log.trace("Filename evaluated as expression: {}", expression); name = expression.evaluate(exchange, String.class); + } else { + name = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, value); } // flatten name diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java index c6a83d2d6a36..0ddc4121344a 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java @@ -22,6 +22,8 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; +import static org.apache.camel.language.simple.SimpleLanguage.simple; + /** * Unit test for expression option for file consumer. */ @@ -70,7 +72,7 @@ public void configure() throws Exception { public void testConsumeFileBasedOnDatePattern() throws Exception { template.sendBodyAndHeader("file://target/filelanguage/date", "Bye World", Exchange.FILE_NAME, "myfile-20081128.txt"); template.sendBodyAndHeader("file://target/filelanguage/date", "Hello World", Exchange.FILE_NAME, "myfile-20081129.txt"); - template.sendBodyAndHeader("file://target/filelanguage/date", "Goodday World", Exchange.FILE_NAME, "myfile-${date:now:yyyyMMdd}.txt"); + template.sendBodyAndHeader("file://target/filelanguage/date", "Goodday World", Exchange.FILE_NAME, simple("myfile-${date:now:yyyyMMdd}.txt")); context.addRoutes(new RouteBuilder() { @Override diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerConsumedFileNameEvaluationTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerConsumedFileNameEvaluationTest.java deleted file mode 100644 index 64da59d0054a..000000000000 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerConsumedFileNameEvaluationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.file; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; - -/** - * @version - */ -public class FileProducerConsumedFileNameEvaluationTest extends ContextTestSupport { - - @Override - protected void setUp() throws Exception { - deleteDirectory("target/producerconsumedfilename"); - super.setUp(); - } - - public void testFileNameNotEvaluatedWhenMatchingConsumed() throws Exception { - Map<String, Object> headers = new TreeMap<String, Object>(); - headers.put(Exchange.FILE_NAME, "file-${date:now:yyyyMMdd}"); - headers.put(Exchange.FILE_NAME_CONSUMED, "file-${date:now:yyyyMMdd}"); - template.sendBodyAndHeaders("file://target/producerconsumedfilename", "Hello World", headers); - assertFileExists("target/producerconsumedfilename/file-${date:now:yyyyMMdd}"); - } - - public void testFileNameEvaluatedWhenNotMatchingConsumed() throws Exception { - Map<String, Object> headers = new TreeMap<String, Object>(); - headers.put(Exchange.FILE_NAME, "file-${date:now:yyyyMMdd}.txt"); - headers.put(Exchange.FILE_NAME_CONSUMED, "file-consumed"); - template.sendBodyAndHeaders("file://target/producerconsumedfilename", "Hello World", headers); - String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); - assertFileExists("target/producerconsumedfilename/file-" + date + ".txt"); - } - - public void testFileNameEvaluatedWhenConsumedNull() throws Exception { - Map<String, Object> headers = new TreeMap<String, Object>(); - headers.put(Exchange.FILE_NAME, "file-${date:now:yyyyMMdd}.txt"); - template.sendBodyAndHeaders("file://target/producerconsumedfilename", "Hello World", headers); - String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); - assertFileExists("target/producerconsumedfilename/file-" + date + ".txt"); - } -} diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java index 684818988e07..208e01fea0ae 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java @@ -25,6 +25,8 @@ import org.apache.camel.Exchange; import org.apache.camel.impl.JndiRegistry; +import static org.apache.camel.language.simple.SimpleLanguage.simple; + /** * Unit test for expression option for file producer. */ @@ -43,11 +45,9 @@ protected JndiRegistry createRegistry() throws Exception { return jndi; } - public void testProduceBeanByHeader() throws Exception { - template.sendBodyAndHeader("file://target/filelanguage", "Hello World", - Exchange.FILE_NAME, "${bean:myguidgenerator}.bak"); - - assertFileExists("target/filelanguage/123.bak"); + public void testProducerFileNameHeaderNotEvaluated() { + template.sendBodyAndHeader("file://target/filelanguage", "Hello World", Exchange.FILE_NAME, "$simple{myfile-${date:now:yyyyMMdd}}.txt"); + assertFileExists("target/filelanguage/$simple{myfile-${date:now:yyyyMMdd}}.txt"); } public void testProduceBeanByExpression() throws Exception { @@ -58,7 +58,7 @@ public void testProduceBeanByExpression() throws Exception { public void testProducerDateByHeader() throws Exception { template.sendBodyAndHeader("file://target/filelanguage", "Hello World", - Exchange.FILE_NAME, "myfile-${date:now:yyyyMMdd}.txt"); + Exchange.FILE_NAME, simple("myfile-${date:now:yyyyMMdd}.txt")); String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); assertFileExists("target/filelanguage/myfile-" + date + ".txt"); diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java index 96b47fa20507..0d63c94d17b4 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java @@ -32,6 +32,8 @@ import org.junit.After; import org.junit.Before; +import static org.apache.camel.language.simple.SimpleLanguage.simple; + /** * Base class for unit testing using a FTPServer */ @@ -127,7 +129,7 @@ protected FtpServerFactory createFtpServerFactory() throws Exception { } public void sendFile(String url, Object body, String fileName) { - template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, fileName); + template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, simple(fileName)); } }
1
aeff00de228bc5a158c2a975ab47845d8a1db456
https://github.com/ImageMagick/ImageMagick/commit/aeff00de228bc5a158c2a975ab47845d8a1db456
Fix a small memory leak
diff --git a/ChangeLog b/ChangeLog index 454a96d846..352f89c671 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 2016-12-10 6.9.6-8 Cristy <quetzlzacatenango@image...> - * Release ImageMagick version 6.9.6-8, GIT revision 11218:2f8c6dd:20161210. + * Release ImageMagick version 6.9.6-8, GIT revision 11219:11d48fe:20161210. 2016-12-07 6.9.6-8 Cristy <quetzlzacatenango@image...> * Set colorspace to sRGB if -append has non-homogenous colorspaces (reference diff --git a/coders/caption.c b/coders/caption.c index 728fc5c8aa..350bed6eb4 100644 --- a/coders/caption.c +++ b/coders/caption.c @@ -275,7 +275,7 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info, draw_info->direction == RightToLeftDirection ? image->columns- metrics.bounds.x2 : -metrics.bounds.x1,0.0),draw_info->gravity == UndefinedGravity ? metrics.ascent : 0.0); - draw_info->geometry=AcquireString(geometry); + (void) CloneString(&draw_info->geometry,geometry); status=AnnotateImage(image,draw_info); if (image_info->pointsize == 0.0) { diff --git a/coders/label.c b/coders/label.c index c5fef43ac7..876354e276 100644 --- a/coders/label.c +++ b/coders/label.c @@ -237,7 +237,7 @@ static Image *ReadLABELImage(const ImageInfo *image_info, draw_info->direction == RightToLeftDirection ? image->columns- metrics.bounds.x2 : 0.0,draw_info->gravity == UndefinedGravity ? metrics.ascent : 0.0); - draw_info->geometry=AcquireString(geometry); + (void) CloneString(&draw_info->geometry,geometry); status=AnnotateImage(image,draw_info); if (image_info->pointsize == 0.0) {
1
e46180776076977d119f3eaa9306dd66eba1bb16
https://github.com/jspahrsummers/libextobjc/commit/e46180776076977d119f3eaa9306dd66eba1bb16
make Xcode7.0.1 happy on OSX
diff --git a/extobjc/EXTRuntimeExtensions.h b/extobjc/EXTRuntimeExtensions.h index ca05826..5f9ee0e 100644 --- a/extobjc/EXTRuntimeExtensions.h +++ b/extobjc/EXTRuntimeExtensions.h @@ -8,6 +8,7 @@ // #import <objc/runtime.h> +#import <Foundation/Foundation.h> /** * A callback indicating that the given method failed to be added to the given
0
c82fc14242ebeab6ac69fe164985cd699a1fc4ff
https://github.com/elastic/elasticsearch/commit/c82fc14242ebeab6ac69fe164985cd699a1fc4ff
[ML] Return 400 status for invalid charset in find_structure (#68201) If an invalid charset argument is supplied to the _text_structure/find_structure endpoint it should return a 400 status. Previously it was returning a 500 status. This change corrects that mistake. Fixes #68130
diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/text_structure/find_file_structure.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/text_structure/find_structure.yml similarity index 87% rename from x-pack/plugin/src/test/resources/rest-api-spec/test/text_structure/find_file_structure.yml rename to x-pack/plugin/src/test/resources/rest-api-spec/test/text_structure/find_structure.yml index 59f99872154c3..3d9e2d53109d9 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/text_structure/find_file_structure.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/text_structure/find_structure.yml @@ -15,15 +15,15 @@ setup: body: - airline: AAL responsetime: 132.2046 - sourcetype: file-structure-test + sourcetype: text-structure-test time: 1403481600 - airline: JZA responsetime: 990.4628 - sourcetype: file-structure-test + sourcetype: text-structure-test time: 1403481700 - airline: AAL responsetime: 134.2046 - sourcetype: file-structure-test + sourcetype: text-structure-test time: 1403481800 - match: { num_lines_analyzed: 3 } @@ -76,15 +76,15 @@ setup: body: - airline: AAL responsetime: 132.2046 - sourcetype: file-structure-test + sourcetype: text-structure-test time: 1403481600 - airline: JZA responsetime: 990.4628 - sourcetype: file-structure-test + sourcetype: text-structure-test time: 1403481700 - airline: AAL responsetime: 134.2046 - sourcetype: file-structure-test + sourcetype: text-structure-test time: 1403481800 - match: { num_lines_analyzed: 3 } @@ -120,3 +120,19 @@ setup: - match: { field_stats.time.earliest: "1403481600" } - match: { field_stats.time.latest: "1403481800" } - match: { explanation.0: "Using specified character encoding [UTF-8]" } + +--- +"Test invalid charset": + - do: + catch: bad_request + headers: + # This is to stop the usual content type randomization, which + # would obviously ruin the results for this particular test + Content-Type: "application/json" + text_structure.find_structure: + charset: wrong + body: + - airline: AAL + responsetime: 132.2046 + sourcetype: text-structure-test + time: 1403481600 diff --git a/x-pack/plugin/text-structure/src/main/java/org/elasticsearch/xpack/textstructure/structurefinder/FileStructureFinderManager.java b/x-pack/plugin/text-structure/src/main/java/org/elasticsearch/xpack/textstructure/structurefinder/FileStructureFinderManager.java index f6fbda24b00ad..798756eace7bb 100644 --- a/x-pack/plugin/text-structure/src/main/java/org/elasticsearch/xpack/textstructure/structurefinder/FileStructureFinderManager.java +++ b/x-pack/plugin/text-structure/src/main/java/org/elasticsearch/xpack/textstructure/structurefinder/FileStructureFinderManager.java @@ -20,6 +20,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -368,9 +369,12 @@ public FileStructureFinder findFileStructure( String charsetName = overrides.getCharset(); Reader sampleReader; if (charsetName != null) { - // Creating the reader will throw if the specified character set does not exist - sampleReader = new InputStreamReader(fromFile, charsetName); - explanation.add("Using specified character encoding [" + charsetName + "]"); + try { + sampleReader = new InputStreamReader(fromFile, charsetName); + explanation.add("Using specified character encoding [" + charsetName + "]"); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException("Supplied character encoding [" + charsetName + "] not available", e); + } } else { CharsetMatch charsetMatch = findCharset(explanation, fromFile, timeoutChecker); charsetName = charsetMatch.getName();
0
6ee0828d510dbebfa121bca9bf95ca1afad802e8
https://github.com/codehaus-plexus/plexus-archiver/commit/6ee0828d510dbebfa121bca9bf95ca1afad802e8
[maven-release-plugin] prepare release plexus-archiver-4.2.3
diff --git a/pom.xml b/pom.xml index 434659eb..a8914f5b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,14 +10,14 @@ </parent> <artifactId>plexus-archiver</artifactId> - <version>4.2.3-SNAPSHOT</version> + <version>4.2.3</version> <name>Plexus Archiver Component</name> <scm> <connection>scm:git:[email protected]:codehaus-plexus/plexus-archiver.git</connection> <developerConnection>scm:git:[email protected]:codehaus-plexus/plexus-archiver.git</developerConnection> <url>http://github.com/codehaus-plexus/plexus-archiver/tree/${project.scm.tag}/</url> - <tag>plexus-archiver-4.2.2</tag> + <tag>plexus-archiver-4.2.3</tag> </scm> <issueManagement> <system>jira</system> @@ -32,7 +32,7 @@ <properties> <javaVersion>7</javaVersion> - <project.build.outputTimestamp>2020-02-29T18:31:25Z</project.build.outputTimestamp> + <project.build.outputTimestamp>2020-10-12T17:44:08Z</project.build.outputTimestamp> </properties> <contributors>
0
d0359c9460eb83759734dd898b1dd633f5477b89
https://github.com/kennethreitz/requests/commit/d0359c9460eb83759734dd898b1dd633f5477b89
Fix broken link
diff --git a/docs/conf.py b/docs/conf.py index eb556a81ba..edbd72ba82 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ # General information about the project. project = u"Requests" -copyright = u'MMXVIX. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project' +copyright = u'MMXVIX. A <a href="https://kenreitz.org/projects">Kenneth Reitz</a> Project' author = u"Kenneth Reitz" # The version info for the project you're documenting, acts as replacement for
0
21baeaed61e2c86fabd7f575f562dde25a600bee
https://github.com/qinxuye/cola/commit/21baeaed61e2c86fabd7f575f562dde25a600bee
add finish callback when job is finished; weibo app will throw ServerBannedError when detecting the banned operation by weibo server
diff --git a/app/weibo/parsers.py b/app/weibo/parsers.py index 99d906f..abb2e73 100755 --- a/app/weibo/parsers.py +++ b/app/weibo/parsers.py @@ -29,7 +29,7 @@ from cola.core.parsers import Parser from cola.core.utils import urldecode, beautiful_soup -from cola.core.errors import DependencyNotInstalledError +from cola.core.errors import DependencyNotInstalledError, FetchBannedError from cola.core.logs import get_logger from login import WeiboLoginFailure @@ -112,8 +112,11 @@ def parse(self, url=None): params['count'] = count params['page'] = page params['pre_page'] = pre_page - - data = json.loads(br.response().read())['data'] + + try: + data = json.loads(br.response().read())['data'] + except (ValueError, KeyError): + raise FetchBannedError('fetch banned by weibo server') soup = beautiful_soup(data) finished = False @@ -274,13 +277,19 @@ def parse(self, url=None): url = url or self.url br = self.opener.browse_open(url) - jsn = json.loads(br.response().read()) + try: + jsn = json.loads(br.response().read()) + except ValueError: + raise FetchBannedError('fetch banned by weibo server') # self.logger.debug('load %s finish' % url) - - soup = beautiful_soup(jsn['data']['html']) - current_page = jsn['data']['page']['pagenum'] - n_pages = jsn['data']['page']['totalpage'] + + try: + soup = beautiful_soup(jsn['data']['html']) + current_page = jsn['data']['page']['pagenum'] + n_pages = jsn['data']['page']['totalpage'] + except KeyError: + raise FetchBannedError('fetch banned by weibo server') if not self.check(url, br): return @@ -624,9 +633,11 @@ def parse(self, url=None): decodes = urldecode(url) is_follow = True is_new_mode = False + is_banned = True for script in soup.find_all('script'): text = script.text if text.startswith('FM.view'): + if is_banned: is_banned = False text = text.strip().replace(';', '').replace('FM.view(', '')[:-1] data = json.loads(text) domid = data['domid'] @@ -637,13 +648,17 @@ def parse(self, url=None): is_follow = False is_new_mode = True elif 'STK' in text: + if is_banned: is_banned = False text = text.replace('STK && STK.pageletM && STK.pageletM.view(', '')[:-1] data = json.loads(text) if data['pid'] == 'pl_relation_hisFollow' or \ data['pid'] == 'pl_relation_hisFans': html = beautiful_soup(data['html']) if data['pid'] == 'pl_relation_hisFans': - is_follow = False + is_follow = False + + if is_banned: + raise FetchBannedError('fetch banned by weibo server') ul = None try: diff --git a/cola/job/__init__.py b/cola/job/__init__.py index a2a759e..f0ef470 100644 --- a/cola/job/__init__.py +++ b/cola/job/__init__.py @@ -52,7 +52,8 @@ class JobRunning(Exception): pass class JobDescription(object): def __init__(self, name, url_patterns, opener_cls, user_conf, starts, - unit_cls=None, login_hook=None, error_handler=None, **kw): + unit_cls=None, login_hook=None, error_handler=None, + finish_callback=None, **kw): self.name = name if not JOB_NAME_RE.match(name): raise ConfigurationError('Job name can only contain alphabet, number and space.') @@ -65,6 +66,7 @@ def __init__(self, name, url_patterns, opener_cls, user_conf, starts, self.starts = starts self.login_hook = login_hook self.error_handler = error_handler + self.finish_callback = finish_callback self.settings = Settings(user_conf=user_conf, **kw) self.unit_cls = unit_cls or \ @@ -285,6 +287,8 @@ def stop_running(self): self.stopped.set() self.wait_for_stop() + if self.job_desc.finish_callback: + self.job_desc.finish_callback() def clear_running(self): if 'main' not in multiprocessing.current_process().name.lower():
0
d78096f7533564eff3de35fc6e6335139118c805
https://github.com/freedomofpress/securedrop/commit/d78096f7533564eff3de35fc6e6335139118c805
Merge pull request #5707 from freedomofpress/singularize-it Make singular strings singular
diff --git a/securedrop/journalist_app/forms.py b/securedrop/journalist_app/forms.py index 6e49319c4a..ad4104b4c0 100644 --- a/securedrop/journalist_app/forms.py +++ b/securedrop/journalist_app/forms.py @@ -28,7 +28,7 @@ def minimum_length_validation(form: FlaskForm, field: Field) -> None: if len(field.data) < Journalist.MIN_USERNAME_LEN: raise ValidationError( ngettext( - 'Must be at least {num} characters long.', + 'Must be at least {num} character long.', 'Must be at least {num} characters long.', Journalist.MIN_USERNAME_LEN ).format(num=Journalist.MIN_USERNAME_LEN) @@ -39,7 +39,7 @@ def name_length_validation(form: FlaskForm, field: Field) -> None: if len(field.data) > Journalist.MAX_NAME_LEN: raise ValidationError( ngettext( - 'Cannot be longer than {num} characters.', + 'Cannot be longer than {num} character.', 'Cannot be longer than {num} characters.', Journalist.MAX_NAME_LEN ).format(num=Journalist.MAX_NAME_LEN) @@ -50,7 +50,7 @@ def check_orgname(form: FlaskForm, field: Field) -> None: if len(field.data) > InstanceConfig.MAX_ORG_NAME_LEN: raise ValidationError( ngettext( - 'Cannot be longer than {num} characters.', + 'Cannot be longer than {num} character.', 'Cannot be longer than {num} characters.', InstanceConfig.MAX_ORG_NAME_LEN ).format(num=InstanceConfig.MAX_ORG_NAME_LEN)
0
8573c2ee172f66c1667de49685c88fdc8883ca8b
https://github.com/openstack-infra/puppet-gerrit/commit/8573c2ee172f66c1667de49685c88fdc8883ca8b
Remove text/html as a safe mimetype The non-default safe mimetype in gerrit exists purely to proect installs against setting this - when set, downloading a text/html file will result in that file being rendered. Change-Id: I648ada0b26aaf35ece9ef57f609b46f23f6e422a
diff --git a/templates/gerrit.config.erb b/templates/gerrit.config.erb index c707f6c..1c922e0 100644 --- a/templates/gerrit.config.erb +++ b/templates/gerrit.config.erb @@ -202,8 +202,6 @@ safe = true [mimetype "text/plain"] safe = true -[mimetype "text/html"] - safe = true [mimetype "text/x-puppet"] safe = true [mimetype "text/x-ini"]
1
0d1fece6e0542c27571aeaa3238562ecb0c29a58
https://github.com/pfsense/FreeBSD-ports/commit/0d1fece6e0542c27571aeaa3238562ecb0c29a58
SquidGuard symlink import fix. Issue #3085
diff --git a/www/pfSense-pkg-squidGuard/files/usr/local/pkg/squidguard_configurator.inc b/www/pfSense-pkg-squidGuard/files/usr/local/pkg/squidguard_configurator.inc index e4cf2baac765..ba717e1ed203 100644 --- a/www/pfSense-pkg-squidGuard/files/usr/local/pkg/squidguard_configurator.inc +++ b/www/pfSense-pkg-squidGuard/files/usr/local/pkg/squidguard_configurator.inc @@ -2170,106 +2170,119 @@ function sg_reconfigure_blacklist($source_filename, $opt = '') # - background rebuild temp DB via sh script (longer proccess) and copy to work DB # ------------------------------------------------------------------------------ -function sg_update_blacklist($from_file) -{ - global $squidguard_config; - $dbhome = SQUIDGUARD_DBHOME; - $workdir = SQUIDGUARD_WORKDIR; - $tmp_unpack_dir = SQUIDGUARD_TMP . SQUIDGUARD_BL_UNPACK; - $arc_db_dir = SQUIDGUARD_TMP . SG_BLK_ARC; - $conf_path = SQUIDGUARD_VAR . DB_REBUILD_BLK_CONF; - $blklist_file = SQUIDGUARD_BLK_FILELISTPATH; - - sg_addlog("sg_update_blacklist", "Begin with '{$from_file}'.", SQUIDGUARD_INFO); - - if (file_exists($from_file)) { - # check work and DB dir's - if (file_exists($squidguard_config[F_DBHOME])) $dbhome = $squidguard_config[F_DBHOME]; - if (file_exists($squidguard_config[F_WORKDIR])) $workdir = $squidguard_config[F_WORKDIR]; - - # delete old tmp dir's - if (file_exists($tmp_unpack_dir)) mwexec("/bin/rm -R {$tmp_unpack_dir}"); - if (file_exists($arc_db_dir)) mwexec("/bin/rm -R {$arc_db_dir}"); - squidguard_ramdisk(false); - - # create new tmp/arc dir's, use ramdisk for quick operations - squidguard_ramdisk(true); - mwexec("/bin/mkdir -p -m 0755 {$tmp_unpack_dir}"); - mwexec("/bin/mkdir -p -m 0755 {$arc_db_dir}"); - - # 1. unpack archive - squidguard_update_log("Unpack archive"); - mwexec("/usr/bin/tar zxvf $from_file -C {$tmp_unpack_dir}"); - set_file_access($tmp_unpack_dir, OWNER_NAME, 0755); - sg_addlog("sg_update_blacklist", "Unpack uploaded file '{$from_file}' -> '{$tmp_unpack_dir}'.", SQUIDGUARD_INFO); - - # 2. copy blacklist to TempDB base & create entries list - squidguard_update_log("Scan blacklist categories."); - if (file_exists($tmp_unpack_dir)) { - $blk_items = array(); - $blk_list = array(); - - # scan blacklist items - scan_blacklist_cat($tmp_unpack_dir, "blk", $blk_items); - - # move blacklist catalog structure to 'one level' (from tmp_DB to arch_DB) - foreach ($blk_items as $key => $val) { - $current_dbpath = "{$arc_db_dir}/{$key}"; - if (count($val)) { - # make blk_list for config file - $blk_list[$key] = $key; - - # delete '$current_dbpath' for correct moving - # need moving $val['path'] to $current_dbpath - # if $current_dbpath exists, then $val['path'] will created as subdir - !it's worng! - if (file_exists($current_dbpath)) - mwexec("/bin/rm -R {$current_dbpath}"); - mwexec("/bin/mv -f {$val['path']}/ {$current_dbpath}"); - sg_addlog("sg_update_blacklist", "Move {$val['path']}/ -> {$current_dbpath}.", SQUIDGUARD_INFO); - } - } - set_file_access($arc_db_dir, OWNER_NAME, 0755); +function sg_update_blacklist($from_file) { + global $squidguard_config; + $dbhome = SQUIDGUARD_DBHOME; + $workdir = SQUIDGUARD_WORKDIR; + $tmp_unpack_dir = SQUIDGUARD_TMP . SQUIDGUARD_BL_UNPACK; + $arc_db_dir = SQUIDGUARD_TMP . SG_BLK_ARC; + $conf_path = SQUIDGUARD_VAR . DB_REBUILD_BLK_CONF; + $blklist_file = SQUIDGUARD_BLK_FILELISTPATH; + + sg_addlog("sg_update_blacklist", "Begin with '{$from_file}'.", SQUIDGUARD_INFO); + + if (file_exists($from_file)) { + # check work and DB dir's + if (file_exists($squidguard_config[F_DBHOME])) { + $dbhome = $squidguard_config[F_DBHOME]; + } + if (file_exists($squidguard_config[F_WORKDIR])) { + $workdir = $squidguard_config[F_WORKDIR]; + } - # create entries list - if (count($blk_items)) { - # save to temp DB - $cont = implode("\n", array_keys($blk_items)); + # delete old tmp dir's + if (file_exists($tmp_unpack_dir)) { + mwexec("/bin/rm -R {$tmp_unpack_dir}"); + } + if (file_exists($arc_db_dir)) { + mwexec("/bin/rm -R {$arc_db_dir}"); + } + squidguard_ramdisk(false); + + # create new tmp/arc dir's, use ramdisk for quick operations + squidguard_ramdisk(true); + mwexec("/bin/mkdir -p -m 0755 {$tmp_unpack_dir}"); + mwexec("/bin/mkdir -p -m 0755 {$arc_db_dir}"); + + # 1. unpack archive + squidguard_update_log("Unpack archive"); + mwexec("/usr/bin/tar zxvf $from_file -C {$tmp_unpack_dir}"); + set_file_access($tmp_unpack_dir, OWNER_NAME, 0755); + sg_addlog("sg_update_blacklist", "Unpack uploaded file '{$from_file}' -> '{$tmp_unpack_dir}'.", SQUIDGUARD_INFO); + + # 2. copy blacklist to TempDB base & create entries list + squidguard_update_log("Scan blacklist categories."); + if (file_exists($tmp_unpack_dir)) { + $blk_items = array(); + $blk_list = array(); + + # scan blacklist items + scan_blacklist_cat($tmp_unpack_dir, "blk", $blk_items); + + # move blacklist catalog structure to 'one level' (from tmp_DB to arch_DB) + foreach ($blk_items as $key => $val) { + $current_dbpath = "{$arc_db_dir}/{$key}"; + if (count($val)) { + if (!file_exists($val['path'])) { + unset($blk_items[$key]); + continue; + } + # make blk_list for config file + $blk_list[$key] = $key; + + # delete '$current_dbpath' for correct moving + # need moving $val['path'] to $current_dbpath + # if $current_dbpath exists, then $val['path'] will created as subdir - !it's worng! + if (file_exists($current_dbpath)) { + mwexec("/bin/rm -R {$current_dbpath}"); + } + mwexec("/bin/mv -f {$val['path']}/ {$current_dbpath}"); + sg_addlog("sg_update_blacklist", "Move {$val['path']}/ -> + {$current_dbpath}.", SQUIDGUARD_INFO); + } + } + set_file_access($arc_db_dir, OWNER_NAME, 0755); - # temp blacklist files - $blklist_file = $arc_db_dir . SQUIDGUARD_BLK_FILELIST; - file_put_contents($blklist_file, $cont); - set_file_access ($blklist_file, OWNER_NAME, 0755); + # create entries list + if (count($blk_items)) { + # save to temp DB + $cont = implode("\n", array_keys($blk_items)); - # system blacklist files - $blklist_file = SQUIDGUARD_BLK_FILELISTPATH; - file_put_contents($blklist_file, $cont); - set_file_access ($blklist_file, OWNER_NAME, 0755); + # temp blacklist files + $blklist_file = $arc_db_dir . SQUIDGUARD_BLK_FILELIST; + file_put_contents($blklist_file, $cont); + set_file_access ($blklist_file, OWNER_NAME, 0755); - sg_addlog("sg_update_blacklist", "Create DB entries list '{$blklist_file}'.", SQUIDGUARD_INFO); - squidguard_update_log("Found " . count($blk_items) . " items."); - } + # system blacklist files + $blklist_file = SQUIDGUARD_BLK_FILELISTPATH; + file_put_contents($blklist_file, $cont); + set_file_access ($blklist_file, OWNER_NAME, 0755); - # rebuild db & save to work dir - squidguard_update_log("Start rebuild DB."); - squidguard_rebuild_db("blk_", $arc_db_dir, $blk_list); + sg_addlog("sg_update_blacklist", "Create DB entries list '{$blklist_file}'.", SQUIDGUARD_INFO); + squidguard_update_log("Found " . count($blk_items) . " items."); + } - squidguard_update_log("Copy DB to workdir."); - $blklist_file = $arc_db_dir . SQUIDGUARD_BLK_FILELIST; - mwexec("/bin/cp -R -p {$arc_db_dir}/ {$dbhome}"); - mwexec("/bin/cp -f -p {$blklist_file} " . SQUIDGUARD_WORKDIR); - set_file_access($dbhome, OWNER_NAME, 0755); + # rebuild db & save to work dir + squidguard_update_log("Start rebuild DB."); + squidguard_rebuild_db("blk_", $arc_db_dir, $blk_list); - squidguard_update_log("Reconfigure Squid proxy."); - mwexec(SQUID_BASE . "/sbin/squid -k reconfigure"); + squidguard_update_log("Copy DB to workdir."); + $blklist_file = $arc_db_dir . SQUIDGUARD_BLK_FILELIST; + mwexec("/bin/cp -R -p {$arc_db_dir}/ {$dbhome}"); + mwexec("/bin/cp -f -p {$blklist_file} " . SQUIDGUARD_WORKDIR); + set_file_access($dbhome, OWNER_NAME, 0755); - squidguard_update_log("Blacklist update complete."); + squidguard_update_log("Reconfigure Squid proxy."); + mwexec(SQUID_BASE . "/sbin/squid -k reconfigure"); - } + squidguard_update_log("Blacklist update complete."); + } - # free ramdisk - squidguard_ramdisk(false); - } - else sg_addlog("sg_update_blacklist", "File {$from_file} not found.", SQUIDGUARD_ERROR); + # free ramdisk + squidguard_ramdisk(false); + } else { + sg_addlog("sg_update_blacklist", "File {$from_file} not found.", SQUIDGUARD_ERROR); + } } # -----------------------------------------------------------------------------
0
4be8a6124fe5364a8a7b7eaa9796679d7487755a
https://github.com/punkave/sanitize-html/commit/4be8a6124fe5364a8a7b7eaa9796679d7487755a
Adds acknowledgement to changelog. (#445)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c93c80..89d7978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.1.3 (2020-12-02): - Adds a note to the README about Typescript support (or the lack-thereof). -- Adds `tel` to the default `allowedSchemes` +- Adds `tel` to the default `allowedSchemes`. Thanks to [Arne Herbots](https://github.com/aHerbots) for this contribution. ## 2.1.2 (2020-11-04): - Fixes typos and inconsistencies in the README. Thanks to [Eric Lefevre-Ardant](https://github.com/elefevre) for this contribution.
0
96849c07dec7989669e70675f17c40e504b440cf
https://github.com/SpiderLabs/ModSecurity/commit/96849c07dec7989669e70675f17c40e504b440cf
Makes action name a shared pointer
diff --git a/headers/modsecurity/actions/action.h b/headers/modsecurity/actions/action.h index 9fb4398be7..db0d254080 100644 --- a/headers/modsecurity/actions/action.h +++ b/headers/modsecurity/actions/action.h @@ -42,7 +42,7 @@ class Action { : m_isNone(false), temporaryAction(false), action_kind(2), - m_name(""), + m_name(nullptr), m_parser_payload("") { set_name_and_payload(_action); } @@ -50,7 +50,7 @@ class Action { : m_isNone(false), temporaryAction(false), action_kind(kind), - m_name(""), + m_name(nullptr), m_parser_payload("") { set_name_and_payload(_action); } @@ -77,11 +77,11 @@ class Action { } if (pos == std::string::npos) { - m_name = data; + m_name = std::shared_ptr<std::string>(new std::string(data)); return; } - m_name = std::string(data, 0, pos); + m_name = std::shared_ptr<std::string>(new std::string(data, 0, pos)); m_parser_payload = std::string(data, pos + 1, data.length()); if (m_parser_payload.at(0) == '\'' && m_parser_payload.size() > 2) { @@ -93,7 +93,7 @@ class Action { bool m_isNone; bool temporaryAction; int action_kind; - std::string m_name; + std::shared_ptr<std::string> m_name; std::string m_parser_payload; /** diff --git a/src/parser/seclang-parser.yy b/src/parser/seclang-parser.yy index f5273c0dce..cf050523d6 100644 --- a/src/parser/seclang-parser.yy +++ b/src/parser/seclang-parser.yy @@ -1171,7 +1171,7 @@ expression: } checkedActions.push_back(a); } else { - driver.error(@0, "The action '" + a->m_name + "' is not suitable to be part of the SecDefaultActions"); + driver.error(@0, "The action '" + *a->m_name.get() + "' is not suitable to be part of the SecDefaultActions"); YYERROR; } } diff --git a/src/rule.cc b/src/rule.cc index b9efefa749..53719f02ae 100644 --- a/src/rule.cc +++ b/src/rule.cc @@ -262,7 +262,7 @@ void Rule::executeActionsIndependentOfChainedRuleResult(Transaction *trans, for (actions::SetVar *a : m_actionsSetVar) { ms_dbg_a(trans, 4, "Running [independent] (non-disruptive) " \ - "action: " + a->m_name); + "action: " + *a->m_name.get()); a->evaluate(this, trans); } @@ -273,12 +273,12 @@ void Rule::executeActionsIndependentOfChainedRuleResult(Transaction *trans, continue; } actions::Action *a = dynamic_cast<actions::Action*>(b.second.get()); - if (a->isDisruptive() == true && a->m_name == "block") { + if (a->isDisruptive() == true && *a->m_name.get() == "block") { ms_dbg_a(trans, 9, "Rule contains a `block' action"); *containsBlock = true; - } else if (a->m_name == "setvar") { + } else if (*a->m_name.get() == "setvar") { ms_dbg_a(trans, 4, "Running [independent] (non-disruptive) " \ - "action: " + a->m_name); + "action: " + *a->m_name.get()); a->evaluate(this, trans, ruleMessage); } } @@ -340,22 +340,21 @@ inline void Rule::executeTransformation(actions::Action *a, if (newValue != *oldValue) { std::shared_ptr<std::string> u(new std::string(newValue)); if (m_containsMultiMatchAction) { - std::shared_ptr<std::string> t(new std::string(a->m_name)); - ret->push_back(std::make_pair(u, t)); + ret->push_back(std::make_pair(u, a->m_name)); (*nth)++; } *value = u; } if (path->empty()) { - path->append(a->m_name); + path->append(*a->m_name.get()); } else { - path->append("," + a->m_name); + path->append("," + *a->m_name.get()); } ms_dbg_a(trans, 9, " T (" + \ std::to_string(*nth) + ") " + \ - a->m_name + ": \"" + \ + *a->m_name.get() + ": \"" + \ utils::string::limitTo(80, newValue) +"\""); } @@ -540,28 +539,28 @@ inline void Rule::getFinalVars(variables::Variables *vars, void Rule::executeAction(Transaction *trans, bool containsBlock, std::shared_ptr<RuleMessage> ruleMessage, Action *a, bool defaultContext) { - if (a->isDisruptive() == false && a->m_name != "block") { + if (a->isDisruptive() == false && *a->m_name.get() != "block") { ms_dbg_a(trans, 9, "Running " \ - "action: " + a->m_name); + "action: " + *a->m_name.get()); a->evaluate(this, trans, ruleMessage); return; } if (defaultContext && !containsBlock) { - ms_dbg_a(trans, 4, "Ignoring action: " + a->m_name + \ + ms_dbg_a(trans, 4, "Ignoring action: " + *a->m_name.get() + \ " (rule does not cotains block)"); return; } if (trans->getRuleEngineState() == RulesSet::EnabledRuleEngine) { - ms_dbg_a(trans, 4, "Running (disruptive) action: " + a->m_name + \ + ms_dbg_a(trans, 4, "Running (disruptive) action: " + *a->m_name.get() + \ "."); a->evaluate(this, trans, ruleMessage); return; } ms_dbg_a(trans, 4, "Not running any disruptive action (or block): " \ - + a->m_name + ". SecRuleEngine is not On."); + + *a->m_name.get() + ". SecRuleEngine is not On."); } @@ -581,7 +580,7 @@ void Rule::executeActionsAfterFullMatch(Transaction *trans, for (actions::Tag *a : this->m_actionsTag) { ms_dbg_a(trans, 4, "Running (non-disruptive) action: " \ - + a->m_name); + + *a->m_name.get()); a->evaluate(this, trans, ruleMessage); } @@ -811,12 +810,12 @@ std::vector<actions::Action *> Rule::getActionsByName(const std::string& name, Transaction *trans) { std::vector<actions::Action *> ret; for (auto &z : m_actionsRuntimePos) { - if (z->m_name == name) { + if (*z->m_name.get() == name) { ret.push_back(z); } } for (auto &z : m_actionsRuntimePre) { - if (z->m_name == name) { + if (*z->m_name.get() == name) { ret.push_back(z); } } @@ -826,7 +825,7 @@ std::vector<actions::Action *> Rule::getActionsByName(const std::string& name, continue; } actions::Action *z = dynamic_cast<actions::Action*>(b.second.get()); - if (z->m_name == name) { + if (*z->m_name.get() == name) { ret.push_back(z); } } @@ -836,7 +835,7 @@ std::vector<actions::Action *> Rule::getActionsByName(const std::string& name, continue; } actions::Action *z = dynamic_cast<actions::Action*>(b.second.get()); - if (z->m_name == name) { + if (*z->m_name.get() == name) { ret.push_back(z); } }
0
d7932a066a43cffcd7cda23c926a1635537ab1a9
https://github.com/sleuthkit/sleuthkit/commit/d7932a066a43cffcd7cda23c926a1635537ab1a9
Add support for storing hosts in the data_source_info table. Added new methods to HostManager.
diff --git a/bindings/java/jni/auto_db_java.cpp b/bindings/java/jni/auto_db_java.cpp index 7cc3888cf3..68c69a3c28 100644 --- a/bindings/java/jni/auto_db_java.cpp +++ b/bindings/java/jni/auto_db_java.cpp @@ -79,7 +79,7 @@ TskAutoDbJava::initializeJni(JNIEnv * jniEnv, jobject jobj) { } m_callbackClass = (jclass)m_jniEnv->NewGlobalRef(localCallbackClass); - m_addImageMethodID = m_jniEnv->GetMethodID(m_callbackClass, "addImageInfo", "(IJLjava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)J"); + m_addImageMethodID = m_jniEnv->GetMethodID(m_callbackClass, "addImageInfo", "(IJLjava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J[Ljava/lang/String;)J"); if (m_addImageMethodID == NULL) { return TSK_ERR; } @@ -216,7 +216,7 @@ TskAutoDbJava::addImageInfo(int type, TSK_OFF_T ssize, int64_t & objId, const st } jlong objIdj = m_jniEnv->CallLongMethod(m_javaDbObj, m_addImageMethodID, - type, ssize, tzj, size, md5j, sha1j, sha256j, devIdj, collj, imgNamesj); + type, ssize, tzj, size, md5j, sha1j, sha256j, devIdj, collj, m_hostId, imgNamesj); objId = (int64_t)objIdj; if (objId < 0) { @@ -936,6 +936,10 @@ int64_t TskAutoDbJava::getImageID() { return m_curImgId; } +void TskAutoDbJava::setHostId(long hostId) { + m_hostId = hostId; +} + void TskAutoDbJava::closeImage() { TskAuto::closeImage(); } diff --git a/bindings/java/jni/auto_db_java.h b/bindings/java/jni/auto_db_java.h index b324a71c43..ae11e6a58a 100644 --- a/bindings/java/jni/auto_db_java.h +++ b/bindings/java/jni/auto_db_java.h @@ -111,6 +111,8 @@ class TskAutoDbJava :public TskAuto { int64_t getImageID(); + void setHostId(long hostId); + TSK_RETVAL_ENUM initializeJni(JNIEnv *, jobject); private: @@ -137,6 +139,7 @@ class TskAutoDbJava :public TskAuto { int64_t m_maxChunkSize; ///< Max number of unalloc bytes to process before writing to the database, even if there is no natural break. -1 for no chunking bool m_foundStructure; ///< Set to true when we find either a volume or file system bool m_attributeAdded; ///< Set to true when an attribute was added by processAttributes + int64_t m_hostId; ///< ID of host for this image (already in database) // These are used to write unallocated blocks for pools at the end of the add image // process. We can't load the pool_info objects directly from the database so we will diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index f4da3b4b62..0688cae469 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -805,13 +805,14 @@ JNIEXPORT jobject JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_hashDbLookup * @param timeZone The time zone for the image. * @param addUnallocSpace Pass true to create virtual files for unallocated space. Ignored if addFileSystems is false. * @param skipFatFsOrphans Pass true to skip processing of orphan files for FAT file systems. Ignored if addFileSystems is false. + * @param hostId Id of the host (already in the database). * * @return A pointer to the process (TskAutoDbJava object) or NULL on error. */ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_initAddImgNat(JNIEnv * env, - jclass obj, jobject callbackObj, jstring timeZone, jboolean addUnallocSpace, jboolean skipFatFsOrphans) { - return Java_org_sleuthkit_datamodel_SleuthkitJNI_initializeAddImgNat(env, obj, callbackObj, timeZone, true, addUnallocSpace, skipFatFsOrphans); + jclass obj, jobject callbackObj, jstring timeZone, jboolean addUnallocSpace, jboolean skipFatFsOrphans, jlong hostId) { + return Java_org_sleuthkit_datamodel_SleuthkitJNI_initializeAddImgNat(env, obj, callbackObj, timeZone, true, addUnallocSpace, skipFatFsOrphans, hostId); } /* @@ -823,12 +824,13 @@ JNIEXPORT jlong JNICALL * @param addFileSystems Pass true to attempt to add file systems within the image to the case database. * @param addUnallocSpace Pass true to create virtual files for unallocated space. Ignored if addFileSystems is false. * @param skipFatFsOrphans Pass true to skip processing of orphan files for FAT file systems. Ignored if addFileSystems is false. + * @param hostId The ID of the host (already in database). * * @return A pointer to the process (TskAutoDbJava object) or NULL on error. */ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_initializeAddImgNat(JNIEnv * env, jclass obj, - jobject callbackObj, jstring timeZone, jboolean addFileSystems, jboolean addUnallocSpace, jboolean skipFatFsOrphans) { + jobject callbackObj, jstring timeZone, jboolean addFileSystems, jboolean addUnallocSpace, jboolean skipFatFsOrphans, jlong hostId) { jboolean isCopy; if (env->GetStringUTFLength(timeZone) > 0) { @@ -864,6 +866,9 @@ Java_org_sleuthkit_datamodel_SleuthkitJNI_initializeAddImgNat(JNIEnv * env, jcla return 0; } + // Save the host ID + tskAutoJava->setHostId(hostId); + // set the options flags tskAutoJava->setAddFileSystems(addFileSystems?true:false); if (addFileSystems) { diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.h b/bindings/java/jni/dataModel_SleuthkitJNI.h index 418db74575..c1808c4220 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.h +++ b/bindings/java/jni/dataModel_SleuthkitJNI.h @@ -170,18 +170,18 @@ JNIEXPORT jobject JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_hashDbLookup /* * Class: org_sleuthkit_datamodel_SleuthkitJNI * Method: initAddImgNat - * Signature: (Lorg/sleuthkit/datamodel/TskCaseDbBridge;Ljava/lang/String;ZZ)J + * Signature: (Lorg/sleuthkit/datamodel/TskCaseDbBridge;Ljava/lang/String;ZZJ)J */ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_initAddImgNat - (JNIEnv *, jclass, jobject, jstring, jboolean, jboolean); + (JNIEnv *, jclass, jobject, jstring, jboolean, jboolean, jlong); /* * Class: org_sleuthkit_datamodel_SleuthkitJNI * Method: initializeAddImgNat - * Signature: (Lorg/sleuthkit/datamodel/TskCaseDbBridge;Ljava/lang/String;ZZZ)J + * Signature: (Lorg/sleuthkit/datamodel/TskCaseDbBridge;Ljava/lang/String;ZZZJ)J */ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_initializeAddImgNat - (JNIEnv *, jclass, jobject, jstring, jboolean, jboolean, jboolean); + (JNIEnv *, jclass, jobject, jstring, jboolean, jboolean, jboolean, jlong); /* * Class: org_sleuthkit_datamodel_SleuthkitJNI diff --git a/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java b/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java index 8497dc7756..0ab4ae7023 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java @@ -187,6 +187,8 @@ private void createFileTables(Statement stmt) throws SQLException { stmt.execute("CREATE TABLE data_source_info (obj_id " + dbQueryHelper.getBigIntType() + " PRIMARY KEY, device_id TEXT NOT NULL, " + "time_zone TEXT NOT NULL, acquisition_details TEXT, added_date_time "+ dbQueryHelper.getBigIntType() + ", " + "acquisition_tool_settings TEXT, acquisition_tool_name TEXT, acquisition_tool_version TEXT, " + + "host_id " + dbQueryHelper.getBigIntType() + ", " + + "FOREIGN KEY(host_id) REFERENCES tsk_hosts(id), " + "FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE)"); stmt.execute("CREATE TABLE tsk_fs_info (obj_id " + dbQueryHelper.getPrimaryKey() + " PRIMARY KEY, " diff --git a/bindings/java/src/org/sleuthkit/datamodel/DataSource.java b/bindings/java/src/org/sleuthkit/datamodel/DataSource.java index 3136038e1f..416abfa3f8 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/DataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/DataSource.java @@ -131,4 +131,13 @@ * @throws TskCoreException Thrown if the data can not be read */ Long getDateAdded() throws TskCoreException; + + /** + * Gets the host for this data source. + * + * @return The host + * + * @throws TskCoreException + */ + Host getHost() throws TskCoreException; } diff --git a/bindings/java/src/org/sleuthkit/datamodel/HostManager.java b/bindings/java/src/org/sleuthkit/datamodel/HostManager.java index f1fe3f49b9..cad1ef8ba3 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/HostManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/HostManager.java @@ -51,6 +51,54 @@ this.db = skCase; } + /** + * APTODO : using for testing - might be able to remove if desired + * Get or create host with specified name. + * + * @param name Host name. + * + * @return Host with the specified name. + * + * @throws TskCoreException + */ + public Host getOrCreateHost(String name) throws TskCoreException { + CaseDbTransaction trans = db.beginTransaction(); + try { + Host host = getOrCreateHost(name, trans); + trans.commit(); + return host; + } catch (TskCoreException ex) { + trans.rollback(); + throw ex; + } + } + + /** + * Get all data sources associated with a given host. + * + * @param host The host. + * + * @return The list of data sources corresponding to the host. + * + * @throws TskCoreException + */ + public Set<DataSource> getDataSourcesForHost(Host host) throws TskCoreException { + String queryString = "SELECT * FROM data_source_info WHERE host_id = " + host.getId(); + + Set<DataSource> dataSources = new HashSet<>(); + try (CaseDbConnection connection = this.db.getConnection(); + Statement s = connection.createStatement(); + ResultSet rs = connection.executeQuery(s, queryString)) { + + while (rs.next()) { + dataSources.add(db.getDataSource(rs.getLong("obj_id"))); + } + + return dataSources; + } catch (SQLException | TskDataException ex) { + throw new TskCoreException(String.format("Error getting data sources for host " + host.getName()), ex); + } + } /** * Get or create host with specified name. @@ -168,4 +216,34 @@ private Host createHost(String name, CaseDbConnection connection) throws TskCore throw new TskCoreException(String.format("Error getting hosts"), ex); } } + + /** + * Get host for the given data source. + * + * @param dataSource The data source to look up the host for. + * + * @return Optional with host. Optional.empty if no matching host is found. + * + * @throws TskCoreException + */ + Host getHost(DataSource dataSource) throws TskCoreException { + + String queryString = "SELECT tsk_hosts.id AS hostId, tsk_hosts.name AS name, tsk_hosts.status AS status FROM \n" + + "tsk_hosts INNER JOIN data_source_info \n" + + "ON tsk_hosts.id = data_source_info.host_id \n" + + "WHERE data_source_info.obj_id = " + dataSource.getId(); + + try (CaseDbConnection connection = this.db.getConnection(); + Statement s = connection.createStatement(); + ResultSet rs = connection.executeQuery(s, queryString)) { + + if (!rs.next()) { + throw new TskCoreException(String.format("Host not found for data source with ID = %d", dataSource.getId())); + } else { + return new Host(rs.getLong("hostId"), rs.getString("name"), Host.HostStatus.fromID(rs.getInt("status"))); + } + } catch (SQLException ex) { + throw new TskCoreException(String.format("Error getting host for data source with ID = %d", dataSource.getId()), ex); + } + } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/Image.java b/bindings/java/src/org/sleuthkit/datamodel/Image.java index 0f71f7ccaf..57284faf6f 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Image.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Image.java @@ -43,6 +43,7 @@ private long size; private final String[] paths; private volatile long imageHandle = 0; + private volatile Host host = null; private final String deviceId, timezone; private String md5, sha1, sha256; private static ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle"); @@ -597,6 +598,23 @@ public Long getDateAdded() throws TskCoreException { public String getAcquisitionDetails() throws TskCoreException { return getSleuthkitCase().getAcquisitionDetails(this); } + + /** + * Gets the host for this data source. + * + * @return The host + * + * @throws TskCoreException + */ + @Override + public Host getHost() throws TskCoreException { + // This is a check-then-act race condition that may occasionally result + // in additional processing but is safer than using locks. + if (host == null) { + host = getSleuthkitCase().getHostManager().getHost(this); + } + return host; + } /** * Updates the image's total size and sector size.This function may be used diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java index e54430c084..f85c55c4d5 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java @@ -39,6 +39,7 @@ private final long objectId; private final String deviceId; private final String timezone; + private volatile Host host; private static final Logger LOGGER = Logger.getLogger(LocalFilesDataSource.class.getName()); @@ -254,6 +255,23 @@ public String getAcquisitionToolName() throws TskCoreException { public String getAcquisitionToolVersion() throws TskCoreException{ return getSleuthkitCase().getDataSourceInfoString(this, "acquisition_tool_version"); } + + /** + * Gets the host for this data source. + * + * @return The host + * + * @throws TskCoreException + */ + @Override + public Host getHost() throws TskCoreException { + // This is a check-then-act race condition that may occasionally result + // in additional processing but is safer than using locks. + if (host == null) { + host = getSleuthkitCase().getHostManager().getHost(this); + } + return host; + } /** * Gets the added date field from the case database. diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index 802f95d132..d44661eb6b 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -6162,19 +6162,50 @@ public LocalDirectory addLocalDirectory(long parentId, String directoryName, Cas * @throws TskCoreException if there is an error adding the data source. */ public LocalFilesDataSource addLocalFilesDataSource(String deviceId, String rootDirectoryName, String timeZone, CaseDbTransaction transaction) throws TskCoreException { + return addLocalFilesDataSource(deviceId, rootDirectoryName, timeZone, null, transaction); + } + + /** + * Adds a local/logical files and/or directories data source. + * + * @param deviceId An ASCII-printable identifier for the device + * associated with the data source that is intended + * to be unique across multiple cases (e.g., a + * UUID). + * @param rootDirectoryName The name for the root virtual directory for the + * data source. + * @param timeZone The time zone used to process the data source, + * may be the empty string. + * @param host The host for the data source (may be null) + * @param transaction A transaction in the scope of which the + * operation is to be performed, managed by the + * caller. + * + * @return The new local files data source. + * + * @throws TskCoreException if there is an error adding the data source. + */ + public LocalFilesDataSource addLocalFilesDataSource(String deviceId, String rootDirectoryName, String timeZone, Host host, CaseDbTransaction transaction) throws TskCoreException { acquireSingleUserCaseWriteLock(); Statement statement = null; try { + CaseDbConnection connection = transaction.getConnection(); + // Insert a row for the root virtual directory of the data source // into the tsk_objects table. - CaseDbConnection connection = transaction.getConnection(); long newObjId = addObject(0, TskData.ObjectType.ABSTRACTFILE.getObjectType(), connection); + // If no host was supplied, make one + if (host == null) { + // APTODO review name + host = getHostManager().getOrCreateHost("LogicalFileSet_" + newObjId + " Host", transaction); + } + // Insert a row for the virtual directory of the data source into // the data_source_info table. statement = connection.createStatement(); - statement.executeUpdate("INSERT INTO data_source_info (obj_id, device_id, time_zone) " - + "VALUES(" + newObjId + ", '" + deviceId + "', '" + timeZone + "');"); + statement.executeUpdate("INSERT INTO data_source_info (obj_id, device_id, time_zone, host_id) " + + "VALUES(" + newObjId + ", '" + deviceId + "', '" + timeZone + "', " + host.getId() + ");"); // Insert a row for the root virtual directory of the data source // into the tsk_files table. Note that its data source object id is @@ -6247,6 +6278,33 @@ public Image addImage(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long size String timezone, String md5, String sha1, String sha256, String deviceId, CaseDbTransaction transaction) throws TskCoreException { + return addImage(type, sectorSize, size, displayName, imagePaths, timezone, md5, sha1, sha256, deviceId, null, transaction); + } + + /** + * Add an image to the database. + * + * @param type Type of image + * @param sectorSize Sector size + * @param size Image size + * @param displayName Display name for the image + * @param imagePaths Image path(s) + * @param timezone Time zone + * @param md5 MD5 hash + * @param sha1 SHA1 hash + * @param sha256 SHA256 hash + * @param deviceId Device ID + * @param host Host + * @param transaction Case DB transaction + * + * @return the newly added Image + * + * @throws TskCoreException + */ + public Image addImage(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long size, String displayName, List<String> imagePaths, + String timezone, String md5, String sha1, String sha256, + String deviceId, Host host, + CaseDbTransaction transaction) throws TskCoreException { acquireSingleUserCaseWriteLock(); Statement statement = null; try { @@ -6280,6 +6338,26 @@ public Image addImage(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long size preparedStatement.setLong(3, i); connection.executeUpdate(preparedStatement); } + + // Create the display name + String name = displayName; + if (name == null || name.isEmpty()) { + if (imagePaths.size() > 0) { + String path = imagePaths.get(0); + name = (new java.io.File(path)).getName(); + } else { + name = ""; + } + } + + // Create a host if needed + if (host == null) { + if (name.isEmpty()) { + getHostManager().getOrCreateHost("Image_" + newObjId + " Host", transaction); + } else { + getHostManager().getOrCreateHost(name + " Host", transaction); + } + } // Add a row to data_source_info preparedStatement = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_DATA_SOURCE_INFO); @@ -6288,18 +6366,10 @@ public Image addImage(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long size preparedStatement.setString(2, deviceId); preparedStatement.setString(3, timezone); preparedStatement.setLong(4, new Date().getTime()); + preparedStatement.setLong(5, host.getId()); connection.executeUpdate(preparedStatement); // Create the new Image object - String name = displayName; - if (name == null || name.isEmpty()) { - if (imagePaths.size() > 0) { - String path = imagePaths.get(0); - name = (new java.io.File(path)).getName(); - } else { - name = ""; - } - } return new Image(this, newObjId, type.getValue(), deviceId, sectorSize, name, imagePaths.toArray(new String[imagePaths.size()]), timezone, md5, sha1, sha256, savedSize); } catch (SQLException ex) { @@ -8690,7 +8760,25 @@ Directory getDirectoryById(long id, FileSystem parentFs) throws TskCoreException * database. */ public Image addImageInfo(long deviceObjId, List<String> imageFilePaths, String timeZone) throws TskCoreException { - long imageId = this.caseHandle.addImageInfo(deviceObjId, imageFilePaths, timeZone, this); + return addImageInfo(deviceObjId, imageFilePaths, timeZone, null); + } + + /** + * Adds an image to the case database. + * + * @param deviceObjId The object id of the device associated with the + * image. + * @param imageFilePaths The image file paths. + * @param timeZone The time zone for the image. + * @param host The host for this image. + * + * @return An Image object. + * + * @throws TskCoreException if there is an error adding the image to case + * database. + */ + public Image addImageInfo(long deviceObjId, List<String> imageFilePaths, String timeZone, Host host) throws TskCoreException { + long imageId = this.caseHandle.addImageInfo(deviceObjId, imageFilePaths, timeZone, host, this); return getImageById(imageId); } @@ -11834,7 +11922,7 @@ long getId() { INSERT_IMAGE_NAME("INSERT INTO tsk_image_names (obj_id, name, sequence) VALUES (?, ?, ?)"), INSERT_IMAGE_INFO("INSERT INTO tsk_image_info (obj_id, type, ssize, tzone, size, md5, sha1, sha256, display_name)" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"), - INSERT_DATA_SOURCE_INFO("INSERT INTO data_source_info (obj_id, device_id, time_zone, added_date_time) VALUES (?, ?, ?, ?)"), + INSERT_DATA_SOURCE_INFO("INSERT INTO data_source_info (obj_id, device_id, time_zone, added_date_time, host_id) VALUES (?, ?, ?, ?, ?)"), INSERT_VS_INFO("INSERT INTO tsk_vs_info (obj_id, vs_type, img_offset, block_size) VALUES (?, ?, ?, ?)"), INSERT_VS_PART_SQLITE("INSERT INTO tsk_vs_parts (obj_id, addr, start, length, desc, flags) VALUES (?, ?, ?, ?, ?, ?)"), INSERT_VS_PART_POSTGRESQL("INSERT INTO tsk_vs_parts (obj_id, addr, start, length, descr, flags) VALUES (?, ?, ?, ?, ?, ?)"), diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java index fbdec24d6c..908ad509c3 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java @@ -438,10 +438,21 @@ void free() throws TskCoreException { * @throws TskCoreException if there is an error adding the image to * case database. */ - long addImageInfo(long deviceObjId, List<String> imageFilePaths, String timeZone, SleuthkitCase skCase) throws TskCoreException { + long addImageInfo(long deviceObjId, List<String> imageFilePaths, String timeZone, Host host, SleuthkitCase skCase) throws TskCoreException { TskCaseDbBridge dbHelper = new TskCaseDbBridge(skCase, new DefaultAddDataSourceCallbacks()); try { - long tskAutoDbPointer = initializeAddImgNat(dbHelper, timezoneLongToShort(timeZone), false, false, false); + if (host == null) { + String hostName; + if (imageFilePaths.size() > 0) { + String path = imageFilePaths.get(0); + hostName = (new java.io.File(path)).getName() + " Host"; + } else { + hostName = "Image_" + deviceObjId + " Host"; + } + host = skCase.getHostManager().getOrCreateHost(hostName); + } + + long tskAutoDbPointer = initializeAddImgNat(dbHelper, timezoneLongToShort(timeZone), false, false, false, host.getId()); runOpenAndAddImgNat(tskAutoDbPointer, UUID.randomUUID().toString(), imageFilePaths.toArray(new String[0]), imageFilePaths.size(), timeZone); long id = finishAddImgNat(tskAutoDbPointer); dbHelper.finish(); @@ -532,7 +543,7 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize) throws Image img = addImageToDatabase(skCase, imageFilePaths, sectorSize, "", "", "", "", deviceId); run(deviceId, img, sectorSize, new DefaultAddDataSourceCallbacks()); } - + /** * Starts the process of adding an image to the case database. * @@ -551,7 +562,35 @@ public void run(String deviceId, String[] imageFilePaths, int sectorSize) throws * the process) */ public void run(String deviceId, Image image, int sectorSize, - AddDataSourceCallbacks addDataSourceCallbacks) throws TskCoreException, TskDataException { + AddDataSourceCallbacks addDataSourceCallbacks) throws TskCoreException, TskDataException { + run(deviceId, image, sectorSize, null, addDataSourceCallbacks); + } + + /** + * Starts the process of adding an image to the case database. + * + * @param deviceId An ASCII-printable identifier for the + * device associated with the image that + * should be unique across multiple cases + * (e.g., a UUID). + * @param image The image object (has already been added to the database) + * @param sectorSize The sector size (no longer used). + * @param host The host for this image (may be null). + * @param addDataSourceCallbacks The callbacks to use to send data to ingest (may do nothing). + * + * @throws TskCoreException if a critical error occurs within the + * SleuthKit. + * @throws TskDataException if a non-critical error occurs within + * the SleuthKit (should be OK to continue + * the process) + */ + public void run(String deviceId, Image image, int sectorSize, Host host, + AddDataSourceCallbacks addDataSourceCallbacks) throws TskCoreException, TskDataException { + + if (host == null) { + host = skCase.getHostManager().getOrCreateHost(image.getName() + " Host"); + } + dbHelper = new TskCaseDbBridge(skCase, addDataSourceCallbacks); getTSKReadLock(); try { @@ -562,7 +601,7 @@ public void run(String deviceId, Image image, int sectorSize, } if (!isCanceled) { //with isCanceled being guarded by this it will have the same value everywhere in this synchronized block imageHandle = image.getImageHandle(); - tskAutoDbPointer = initAddImgNat(dbHelper, timezoneLongToShort(timeZone), addUnallocSpace, skipFatFsOrphans); + tskAutoDbPointer = initAddImgNat(dbHelper, timezoneLongToShort(timeZone), addUnallocSpace, skipFatFsOrphans, host.getId()); } if (0 == tskAutoDbPointer) { throw new TskCoreException("initAddImgNat returned a NULL TskAutoDb pointer"); @@ -940,6 +979,29 @@ private static void cacheImageHandle(SleuthkitCase skCase, List<String> imagePat public static Image addImageToDatabase(SleuthkitCase skCase, String[] imagePaths, int sectorSize, String timeZone, String md5fromSettings, String sha1fromSettings, String sha256fromSettings, String deviceId) throws TskCoreException { + return addImageToDatabase(skCase, imagePaths, sectorSize, timeZone, md5fromSettings, sha1fromSettings, sha256fromSettings, deviceId, null); + } + + /** + * Add an image to the database and return the open image. + * + * @param skCase The current case. + * @param imagePaths The path(s) to the image (will just be the first for .e01, .001, etc). + * @param sectorSize The sector size (0 for auto-detect). + * @param timeZone The time zone. + * @param md5fromSettings MD5 hash (if known). + * @param sha1fromSettings SHA1 hash (if known). + * @param sha256fromSettings SHA256 hash (if known). + * @param deviceId Device ID. + * @param host Host. + * + * @return The Image object. + * + * @throws TskCoreException + */ + public static Image addImageToDatabase(SleuthkitCase skCase, String[] imagePaths, int sectorSize, + String timeZone, String md5fromSettings, String sha1fromSettings, String sha256fromSettings, String deviceId, Host host) throws TskCoreException { + // Open the image long imageHandle = openImgNat(imagePaths, 1, sectorSize); @@ -967,10 +1029,21 @@ public static Image addImageToDatabase(SleuthkitCase skCase, String[] imagePaths // Now save to database CaseDbTransaction transaction = skCase.beginTransaction(); try { + if (host == null) { + String hostName; + if (computedPaths.size() > 0) { + String path = computedPaths.get(0); + hostName = (new java.io.File(path)).getName() + " Host"; + } else { + hostName = "Image_" + deviceId + " Host"; + } + host = skCase.getHostManager().getOrCreateHost(hostName, transaction); + } + Image img = skCase.addImage(TskData.TSK_IMG_TYPE_ENUM.valueOf(type), computedSectorSize, size, null, computedPaths, timeZone, md5, sha1, sha256, - deviceId, transaction); + deviceId, host, transaction); if (!StringUtils.isEmpty(collectionDetails)) { skCase.setAcquisitionDetails(img, collectionDetails); } @@ -2096,9 +2169,9 @@ public static long openFile(long fsHandle, long fileId, TSK_FS_ATTR_TYPE_ENUM at private static native HashHitInfo hashDbLookupVerbose(String hash, int dbHandle) throws TskCoreException; - private static native long initAddImgNat(TskCaseDbBridge dbHelperObj, String timezone, boolean addUnallocSpace, boolean skipFatFsOrphans) throws TskCoreException; + private static native long initAddImgNat(TskCaseDbBridge dbHelperObj, String timezone, boolean addUnallocSpace, boolean skipFatFsOrphans, long hostId) throws TskCoreException; - private static native long initializeAddImgNat(TskCaseDbBridge dbHelperObj, String timezone, boolean addFileSystems, boolean addUnallocSpace, boolean skipFatFsOrphans) throws TskCoreException; + private static native long initializeAddImgNat(TskCaseDbBridge dbHelperObj, String timezone, boolean addFileSystems, boolean addUnallocSpace, boolean skipFatFsOrphans, long hostId) throws TskCoreException; private static native void runOpenAndAddImgNat(long process, String deviceId, String[] imgPath, int splits, String timezone) throws TskCoreException, TskDataException; diff --git a/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java b/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java index cee51945ac..36cc1d257c 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java @@ -123,16 +123,18 @@ void finish() { * @param sha256 SHA256 hash. * @param deviceId Device ID. * @param collectionDetails The collection details. + * @param hostId Host ID. + * @param paths Data source path(s) * * @return The object ID of the new image or -1 if an error occurred */ long addImageInfo(int type, long ssize, String timezone, long size, String md5, String sha1, String sha256, String deviceId, - String collectionDetails, String[] paths) { + String collectionDetails, long hostId, String[] paths) { try { beginTransaction(); long objId = addImageToDb(TskData.TSK_IMG_TYPE_ENUM.valueOf(type), ssize, size, - timezone, md5, sha1, sha256, deviceId, collectionDetails, trans); + timezone, md5, sha1, sha256, deviceId, collectionDetails, hostId, trans); for (int i = 0;i < paths.length;i++) { addImageNameToDb(objId, paths[i], i, trans); } @@ -913,6 +915,7 @@ private long addFileToDb(long parentObjId, * @param sha256 SHA256 hash. * @param deviceId Device ID. * @param collectionDetails Collection details. + * @param hostId The ID of a host already in the database. * @param transaction Case DB transaction. * * @return The newly added Image object ID. @@ -921,7 +924,7 @@ private long addFileToDb(long parentObjId, */ private long addImageToDb(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long size, String timezone, String md5, String sha1, String sha256, - String deviceId, String collectionDetails, + String deviceId, String collectionDetails, long hostId, CaseDbTransaction transaction) throws TskCoreException { try { // Insert a row for the Image into the tsk_objects table. @@ -948,13 +951,14 @@ private long addImageToDb(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long connection.executeUpdate(preparedStatement); // Add a row to data_source_info - String dataSourceInfoSql = "INSERT INTO data_source_info (obj_id, device_id, time_zone, acquisition_details) VALUES (?, ?, ?, ?)"; // NON-NLS + String dataSourceInfoSql = "INSERT INTO data_source_info (obj_id, device_id, time_zone, acquisition_details, host_id) VALUES (?, ?, ?, ?, ?)"; // NON-NLS preparedStatement = connection.getPreparedStatement(dataSourceInfoSql, Statement.NO_GENERATED_KEYS); preparedStatement.clearParameters(); preparedStatement.setLong(1, newObjId); preparedStatement.setString(2, deviceId); preparedStatement.setString(3, timezone); preparedStatement.setString(4, collectionDetails); + preparedStatement.setLong(5, hostId); connection.executeUpdate(preparedStatement); return newObjId;
0
5bc74d06dad35d00b5925b1c76208aeaf40a2dbb
https://github.com/FFmpeg/FFmpeg/commit/5bc74d06dad35d00b5925b1c76208aeaf40a2dbb
avcodec/utils: Only call codec->close if init has been called avcodec_open2() also called the AVCodec's close function if an error happened before init had ever been called if the AVCodec has the FF_CODEC_CAP_INIT_CLEANUP flag set. This is against the documentation of said flag: "The codec allows calling the close function for deallocation even if the init function returned a failure." E.g. the SVQ3 decoder is not ready to be closed if init has never been called. Fixes: NULL dereference Fixes: 25762/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5716279070294016 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <[email protected]> Reviewed-by: Michael Niedermayer <[email protected]> Signed-off-by: Andreas Rheinhardt <[email protected]>
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cf0a55f26d15..94b9e94584ce 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -931,6 +931,7 @@ FF_ENABLE_DEPRECATION_WARNINGS || avci->frame_thread_encoder)) { ret = avctx->codec->init(avctx); if (ret < 0) { + codec_init_ok = -1; goto free_and_end; } codec_init_ok = 1; @@ -1022,8 +1023,8 @@ FF_ENABLE_DEPRECATION_WARNINGS return ret; free_and_end: if (avctx->codec && avctx->codec->close && - (codec_init_ok || - (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))) + (codec_init_ok > 0 || (codec_init_ok < 0 && + avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))) avctx->codec->close(avctx); if (HAVE_THREADS && avci->thread_ctx)
0
01ff2bc5d3cb60a9bba508ed3143d0d15b40d555
https://github.com/restlet/restlet-framework-java/commit/01ff2bc5d3cb60a9bba508ed3143d0d15b40d555
Removed Wiki uri references.
diff --git a/build/project.xml b/build/project.xml index c495021584..7a479ee349 100644 --- a/build/project.xml +++ b/build/project.xml @@ -14,7 +14,6 @@ <distribution id="classic" /> <distribution id="maven" /> </distributions> - <wikiUri>../editions/jse/</wikiUri> </edition> <edition id="jee"> <label> @@ -32,7 +31,6 @@ <distribution id="classic" /> <distribution id="maven" /> </distributions> - <wikiUri>../editions/jee/</wikiUri> </edition> <edition id="osgi"> <label> @@ -49,7 +47,6 @@ <distribution id="maven" /> <distribution id="p2" /> </distributions> - <wikiUri>../editions/osgi/</wikiUri> </edition> <edition id="gae"> <label> @@ -66,7 +63,6 @@ <distribution id="classic" /> <distribution id="maven" /> </distributions> - <wikiUri>../editions/gae/</wikiUri> </edition> <edition id="gwt"> <label> @@ -98,7 +94,6 @@ <replace dir="${mod}/${module.package}" includes="**/.project" token="org.restlet.client" value="org.restlet.${edition}" /> ]]> </postSource> - <wikiUri>../editions/gwt/</wikiUri> </edition> <edition id="android"> <label> @@ -116,6 +111,5 @@ <distribution id="classic" /> <distribution id="maven" /> </distributions> - <wikiUri>../editions/android/</wikiUri> </edition> -</editions> \ No newline at end of file +</editions> diff --git a/modules/org.restlet.ext.e4/.project b/modules/org.restlet.ext.e4/.project deleted file mode 100644 index fcea8397c6..0000000000 --- a/modules/org.restlet.ext.e4/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.restlet.ext.e4</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/modules/org.restlet.ext.fileupload/module.xml b/modules/org.restlet.ext.fileupload/module.xml index 69f0332072..0c49670583 100644 --- a/modules/org.restlet.ext.fileupload/module.xml +++ b/modules/org.restlet.ext.fileupload/module.xml @@ -13,5 +13,4 @@ <dependency type="module" id="core" /> <dependency type="module" id="servlet" includes="gae,jee" /> </dependencies> - <wikiUri>64-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.freemarker/module.xml b/modules/org.restlet.ext.freemarker/module.xml index 4d8085d893..e2b9143c92 100644 --- a/modules/org.restlet.ext.freemarker/module.xml +++ b/modules/org.restlet.ext.freemarker/module.xml @@ -11,5 +11,4 @@ <dependency type="library" id="freemarker" primary="true" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>66-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.gae/module.xml b/modules/org.restlet.ext.gae/module.xml index 93c061b740..f5a155ff63 100644 --- a/modules/org.restlet.ext.gae/module.xml +++ b/modules/org.restlet.ext.gae/module.xml @@ -10,5 +10,4 @@ <dependency type="module" id="core" /> <dependency type="library" id="appengine" /> </dependencies> - <wikiUri>405-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.guice/module.xml b/modules/org.restlet.ext.guice/module.xml index 3f9eb9f43c..4e2db4c049 100644 --- a/modules/org.restlet.ext.guice/module.xml +++ b/modules/org.restlet.ext.guice/module.xml @@ -12,7 +12,4 @@ <dependency type="library" id="aopalliance" /> <dependency type="module" id="core" /> </dependencies> - <!-- - <wikiUri>66-restlet</wikiUri> - --> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.gwt/module.xml b/modules/org.restlet.ext.gwt/module.xml index 4eaea0c63e..76bbb9a135 100644 --- a/modules/org.restlet.ext.gwt/module.xml +++ b/modules/org.restlet.ext.gwt/module.xml @@ -20,5 +20,4 @@ ]]> </files-sets> </source> - <wikiUri>315-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.html/module.xml b/modules/org.restlet.ext.html/module.xml index 7150845660..89d260a5e8 100644 --- a/modules/org.restlet.ext.html/module.xml +++ b/modules/org.restlet.ext.html/module.xml @@ -10,5 +10,4 @@ <dependencies> <dependency type="module" id="core" /> </dependencies> - <wikiUri>412-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.httpclient/module.xml b/modules/org.restlet.ext.httpclient/module.xml index 997a754c41..cd193f4c29 100644 --- a/modules/org.restlet.ext.httpclient/module.xml +++ b/modules/org.restlet.ext.httpclient/module.xml @@ -17,5 +17,4 @@ <dependency type="library" id="mime4j" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>75-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.jaas/module.xml b/modules/org.restlet.ext.jaas/module.xml index 4bb12f4a60..9279942524 100644 --- a/modules/org.restlet.ext.jaas/module.xml +++ b/modules/org.restlet.ext.jaas/module.xml @@ -9,5 +9,4 @@ <dependencies> <dependency type="module" id="core" /> </dependencies> - <wikiUri>67-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.jackson/module.xml b/modules/org.restlet.ext.jackson/module.xml index d8f4c67293..517db3bfd7 100644 --- a/modules/org.restlet.ext.jackson/module.xml +++ b/modules/org.restlet.ext.jackson/module.xml @@ -55,5 +55,4 @@ ]]> </files-sets> </source> - <wikiUri>299-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.javamail/module.xml b/modules/org.restlet.ext.javamail/module.xml index c24c6951e0..131381aff3 100644 --- a/modules/org.restlet.ext.javamail/module.xml +++ b/modules/org.restlet.ext.javamail/module.xml @@ -12,5 +12,4 @@ <dependency type="module" id="core" /> <dependency type="module" id="xml" /> </dependencies> - <wikiUri>76-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.jaxb/module.xml b/modules/org.restlet.ext.jaxb/module.xml index b6131664b7..6b236e7c0b 100644 --- a/modules/org.restlet.ext.jaxb/module.xml +++ b/modules/org.restlet.ext.jaxb/module.xml @@ -11,5 +11,4 @@ <dependency type="library" id="jaxb-ri" primary="true"/> <dependency type="module" id="core" /> </dependencies> - <wikiUri>67-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.jaxrs/module.xml b/modules/org.restlet.ext.jaxrs/module.xml index 20335af067..9c924f24df 100644 --- a/modules/org.restlet.ext.jaxrs/module.xml +++ b/modules/org.restlet.ext.jaxrs/module.xml @@ -39,5 +39,4 @@ ]]> </files-sets> </source> - <wikiUri>57-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.jibx/module.xml b/modules/org.restlet.ext.jibx/module.xml index 17c3fc0bcb..2d74a61c21 100644 --- a/modules/org.restlet.ext.jibx/module.xml +++ b/modules/org.restlet.ext.jibx/module.xml @@ -11,5 +11,4 @@ <dependency type="library" id="jibx" primary="true" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>68-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.json/module.xml b/modules/org.restlet.ext.json/module.xml index 113f49ca1c..85291ea4ba 100644 --- a/modules/org.restlet.ext.json/module.xml +++ b/modules/org.restlet.ext.json/module.xml @@ -32,5 +32,4 @@ </files-sets> </source> <stage edition="gwt" includesource="true" /> - <wikiUri>69-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.jsslutils/.project b/modules/org.restlet.ext.jsslutils/.project deleted file mode 100644 index 4007aada6c..0000000000 --- a/modules/org.restlet.ext.jsslutils/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.restlet.ext.jsslutils</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/modules/org.restlet.ext.lucene/module.xml b/modules/org.restlet.ext.lucene/module.xml index f27688bdac..a1f137ac24 100644 --- a/modules/org.restlet.ext.lucene/module.xml +++ b/modules/org.restlet.ext.lucene/module.xml @@ -15,5 +15,4 @@ <dependency type="module" id="core" /> <dependency type="module" id="xml" /> </dependencies> - <wikiUri>229-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.nio/module.xml b/modules/org.restlet.ext.nio/module.xml index 66ad63ced0..c85f78d377 100644 --- a/modules/org.restlet.ext.nio/module.xml +++ b/modules/org.restlet.ext.nio/module.xml @@ -10,5 +10,4 @@ <dependencies> <dependency type="module" id="core" /> </dependencies> - <wikiUri>79-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.oauth/module.xml b/modules/org.restlet.ext.oauth/module.xml index 7849ada1a0..eea917657c 100644 --- a/modules/org.restlet.ext.oauth/module.xml +++ b/modules/org.restlet.ext.oauth/module.xml @@ -30,5 +30,4 @@ </repositories> ]]> </maven-misc> - <wikiUri>392-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.odata/module.xml b/modules/org.restlet.ext.odata/module.xml index ef68e1605a..1df8f362e9 100644 --- a/modules/org.restlet.ext.odata/module.xml +++ b/modules/org.restlet.ext.odata/module.xml @@ -30,5 +30,4 @@ ]]> </files-sets> </source> - <wikiUri>287-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.openid/module.xml b/modules/org.restlet.ext.openid/module.xml index 7cfedb788e..e3db4821da 100644 --- a/modules/org.restlet.ext.openid/module.xml +++ b/modules/org.restlet.ext.openid/module.xml @@ -17,5 +17,4 @@ <dependency type="module" id="xml"/> <dependency type="module" id="json"/> </dependencies> - <wikiUri>404-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.osgi/module.xml b/modules/org.restlet.ext.osgi/module.xml index 42e217c80a..51830e1a61 100644 --- a/modules/org.restlet.ext.osgi/module.xml +++ b/modules/org.restlet.ext.osgi/module.xml @@ -12,6 +12,4 @@ <dependency type="library" id="osgi" maven-scope="compile" /> <dependency type="library" id="e4" maven-scope="compile" /> </dependencies> - <wikiUri>TODO</wikiUri> - -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.raml/module.xml b/modules/org.restlet.ext.raml/module.xml index 8e2d304248..9bce527341 100644 --- a/modules/org.restlet.ext.raml/module.xml +++ b/modules/org.restlet.ext.raml/module.xml @@ -16,5 +16,4 @@ <dependency type="module" id="jackson" /> <dependency type="module" id="apispark" /> </dependencies> - <!--<wikiUri>xx-tobedefined</wikiUri> --> </module> diff --git a/modules/org.restlet.ext.rdf/module.xml b/modules/org.restlet.ext.rdf/module.xml index e8625a3c4b..38fd3b45a9 100644 --- a/modules/org.restlet.ext.rdf/module.xml +++ b/modules/org.restlet.ext.rdf/module.xml @@ -11,5 +11,4 @@ <dependency type="module" id="core" /> <dependency type="module" id="xml" /> </dependencies> - <wikiUri>270-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.servlet/module.xml b/modules/org.restlet.ext.servlet/module.xml index 6d44dd0384..1b40561230 100644 --- a/modules/org.restlet.ext.servlet/module.xml +++ b/modules/org.restlet.ext.servlet/module.xml @@ -33,5 +33,4 @@ ]]> </files-sets> </source> - <wikiUri>81-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.simple/module.xml b/modules/org.restlet.ext.simple/module.xml index 13c3afd714..47ee85a112 100644 --- a/modules/org.restlet.ext.simple/module.xml +++ b/modules/org.restlet.ext.simple/module.xml @@ -11,5 +11,4 @@ <dependency type="library" id="simple" primary="true" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>82-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.slf4j/module.xml b/modules/org.restlet.ext.slf4j/module.xml index 7832d8c510..81192b9c5b 100644 --- a/modules/org.restlet.ext.slf4j/module.xml +++ b/modules/org.restlet.ext.slf4j/module.xml @@ -11,5 +11,4 @@ <dependency type="library" id="slf4j" primary="true" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>316-restlet</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.spring/module.xml b/modules/org.restlet.ext.spring/module.xml index 12e2666a81..99fe728385 100644 --- a/modules/org.restlet.ext.spring/module.xml +++ b/modules/org.restlet.ext.spring/module.xml @@ -26,5 +26,4 @@ classpathref="forge-path" from=".MF.gae" to=".MF" /> ]]> </files-mappers> <files-sets> <![CDATA[ <exclude name="META-INF/MANIFEST.MF" /> <exclude name="src/org/restlet/ext/spring/*Servlet.java" /> ]]> </files-sets> </source> --> - <wikiUri>70-restlet</wikiUri> </module> diff --git a/modules/org.restlet.ext.swagger/module.xml b/modules/org.restlet.ext.swagger/module.xml index 61b3784ac3..d3acc723f5 100644 --- a/modules/org.restlet.ext.swagger/module.xml +++ b/modules/org.restlet.ext.swagger/module.xml @@ -18,7 +18,6 @@ <dependency type="module" id="jaxrs" /> <dependency type="module" id="apispark" /> </dependencies> -<!-- <wikiUri>xx-tobedefined</wikiUri> --> <!-- Remove some classes to be refactored. --> <source edition="android"> <files-sets> diff --git a/modules/org.restlet.ext.thymeleaf/module.xml b/modules/org.restlet.ext.thymeleaf/module.xml index af082da126..8b45be694b 100644 --- a/modules/org.restlet.ext.thymeleaf/module.xml +++ b/modules/org.restlet.ext.thymeleaf/module.xml @@ -11,5 +11,4 @@ <dependency type="library" id="thymeleaf" primary="true" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>to-do</wikiUri> -</module> \ No newline at end of file +</module> diff --git a/modules/org.restlet.ext.velocity/module.xml b/modules/org.restlet.ext.velocity/module.xml index 12d69edd0d..4ec5975c5d 100644 --- a/modules/org.restlet.ext.velocity/module.xml +++ b/modules/org.restlet.ext.velocity/module.xml @@ -13,5 +13,4 @@ <dependency type="library" id="velocity" primary="true" /> <dependency type="module" id="core" /> </dependencies> - <wikiUri>71-restlet</wikiUri> </module> \ No newline at end of file diff --git a/modules/org.restlet.ext.wadl/module.xml b/modules/org.restlet.ext.wadl/module.xml index 0ae2003e17..afbd32d01b 100644 --- a/modules/org.restlet.ext.wadl/module.xml +++ b/modules/org.restlet.ext.wadl/module.xml @@ -14,8 +14,6 @@ <dependency includes="osgi" type="library" id="osgi" maven-scope="compile" /> <dependency includes="osgi" type="library" id="e4" maven-scope="compile" /> </dependencies> - <wikiUri>72-restlet</wikiUri> - <source edition="gae"> <files-sets> <![CDATA[ diff --git a/modules/org.restlet.ext.xml/module.xml b/modules/org.restlet.ext.xml/module.xml index 8e6f4547ec..b89bb0b0c1 100644 --- a/modules/org.restlet.ext.xml/module.xml +++ b/modules/org.restlet.ext.xml/module.xml @@ -42,5 +42,4 @@ </files-sets> </source> <stage edition="gwt" includesource="true" /> - <wikiUri>317-restlet</wikiUri> </module>
0
9961918e6e9d1412017a34745cee14d6a6f29df0
https://github.com/ashinn/irregex/commit/9961918e6e9d1412017a34745cee14d6a6f29df0
Exclude vector-copy when importing (scheme base). vector-copy is exported by (scheme base), and also definied in irregex.scm, which leads to an error. Perhaps it would be better to use the (scheme base) version of vector-copy, but excluding vector-copy from the (scheme base) import seems to be OK too.
diff --git a/irregex.sld b/irregex.sld index c0c36c1..82ef83f 100644 --- a/irregex.sld +++ b/irregex.sld @@ -15,5 +15,5 @@ irregex-dfa irregex-dfa/search irregex-nfa irregex-flags irregex-lengths irregex-names irregex-num-submatches irregex-extract irregex-split) - (import (scheme base) (scheme char) (scheme cxr)) + (import (except (scheme base) vector-copy) (scheme char) (scheme cxr)) (include "irregex.scm"))
0
37cd3c5a408b58a5a8ba9e8ac716a57fc7eb9a96
https://github.com/Studio-42/elFinder/commit/37cd3c5a408b58a5a8ba9e8ac716a57fc7eb9a96
[VD:OneDrive] bugfix of large file uploading
diff --git a/php/elFinderVolumeOneDrive.class.php b/php/elFinderVolumeOneDrive.class.php index 402fa2ee5b..32d335b321 100644 --- a/php/elFinderVolumeOneDrive.class.php +++ b/php/elFinderVolumeOneDrive.class.php @@ -581,7 +581,8 @@ protected function _od_uploadSession($fp, $size, $name, $itemId, $parent, $paren elFinder::extendTimeLimit(); $putFp = tmpfile(); fwrite($putFp, $send); - fseek($putFp, 0); + rewind($putFp); + $_size = strlen($send); $url = $sess->uploadUrl; $curl = curl_init(); $options = array( @@ -589,8 +590,9 @@ protected function _od_uploadSession($fp, $size, $name, $itemId, $parent, $paren CURLOPT_PUT => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_INFILE => $putFp, + CURLOPT_INFILESIZE => $_size, CURLOPT_HTTPHEADER => array( - 'Content-Length: ' . strlen($send), + 'Content-Length: ' . $_size, 'Content-Range: bytes ' . $range, ), );
0
5af00d22e5ecca617a3b314b6f71965718a5e8d8
https://github.com/videolan/vlc-ios/commit/5af00d22e5ecca617a3b314b6f71965718a5e8d8
l10n: Thai update Localizable.strings: 100% translated InfoPlist.strings: 100% translated Settings.bundle: 100% translated Signed-off-by: Michał Trzebiatowski <[email protected]>
diff --git a/Apple-TV/Settings.bundle/th.lproj/Root.strings b/Apple-TV/Settings.bundle/th.lproj/Root.strings index d2d9161f0..bce0307fa 100644 --- a/Apple-TV/Settings.bundle/th.lproj/Root.strings +++ b/Apple-TV/Settings.bundle/th.lproj/Root.strings @@ -100,7 +100,7 @@ "SETTINGS_BACKUP_MEDIA_LIBRARY" = "รวมไลบรารีสื่อในการสำรองข้อมูลอุปกรณ์"; "SETTINGS_FILE_SYNC" = "เชื่อมโยงไฟล์"; -"SETTINGS_WIFISHARING_IPv6" = "IPv6 support for Wi-Fi Sharing"; +"SETTINGS_WIFISHARING_IPv6" = "การรองรับ IPv6 สำหรับการแชร์ด้วย Wi-Fi"; "SETTINGS_ARTWORK" = "งานศิลปะ"; "SETTINGS_DOWNLOAD_ARTWORK" = "ดาวน์โหลดงานศิลปะ"; diff --git a/Resources/Settings.bundle/th.lproj/Root.strings b/Resources/Settings.bundle/th.lproj/Root.strings index d2d9161f0..bce0307fa 100644 --- a/Resources/Settings.bundle/th.lproj/Root.strings +++ b/Resources/Settings.bundle/th.lproj/Root.strings @@ -100,7 +100,7 @@ "SETTINGS_BACKUP_MEDIA_LIBRARY" = "รวมไลบรารีสื่อในการสำรองข้อมูลอุปกรณ์"; "SETTINGS_FILE_SYNC" = "เชื่อมโยงไฟล์"; -"SETTINGS_WIFISHARING_IPv6" = "IPv6 support for Wi-Fi Sharing"; +"SETTINGS_WIFISHARING_IPv6" = "การรองรับ IPv6 สำหรับการแชร์ด้วย Wi-Fi"; "SETTINGS_ARTWORK" = "งานศิลปะ"; "SETTINGS_DOWNLOAD_ARTWORK" = "ดาวน์โหลดงานศิลปะ"; diff --git a/Resources/th.lproj/Localizable.strings b/Resources/th.lproj/Localizable.strings index cbb31cf20..289f52076 100644 --- a/Resources/th.lproj/Localizable.strings +++ b/Resources/th.lproj/Localizable.strings @@ -1,4 +1,4 @@ -"STORE_DESCRIPTION" = "VLC for iOS is a port of the free VLC media player to iPad, iPhone and iPod touch.\nIt can play all your movies, shows and music in most formats directly without conversion.\nIt allows file synchronization with Dropbox, GDrive, OneDrive, Box, iCloud Drive, iTunes, direct downloads and through Wi-Fi sharing as well as streaming from SMB, FTP, UPnP/DLNA media servers and the web.\nVLC offers support for advanced subtitles including full SSA compatibility, multi-track audio, and playback speed control.\n\nVLC for iOS is completely free and open source."; +"STORE_DESCRIPTION" = "VLC สำหรับ iOS คือช่องทางฟรีของโปรแกรมเล่นสื่อ VLC บน iPad, iPhone และ iPod touch\nคุณสามารถเล่นภาพยนตร์ รายการ และเพลงทั้งหมดของคุณในรูปแบบต่าง ๆ ได้โดยตรงโดยไม่ต้องแปลงไฟล์\nคุณสามารถซิงค์ไฟล์กับ Dropbox, GDrive, OneDrive, Box, iCloud Drive, iTunes, การดาวน์โหลดโดยตรงและผ่านทางการแชร์บน Wi-Fi และการสตรีมจาก SMB, FTP, เซิร์ฟเวอร์สื่อ UPnP/DLNA และเว็บ\nVLC รองรับกับคำบรรยายขั้นสูง รวมทั้งเข้ากันได้กับ SSA แบบเต็ม, ระบบเสียงมัลติแทร็ก และการควบคุมความเร็วการเล่น\n\nVLC สำหรับ iOS นั้นฟรีอย่างสมบูรณ์และเป็นโอเพนซอร์ส"; "STORE_DESCRIPTION_TV" = "โปรแกรมเล่นสื่อ VLC ฟรีและเป็นโปรแกรมเล่นมัลติมีเดียโอเพนซอร์สข้ามแพลตฟอร์ม\nคุณสามารถเล่นภาพยนตร์ รายการ และเพลงทั้งหมดของคุณในรูปแบบส่วนใหญ่ได้โดยตรงโดยไม่ต้องแปลงไฟล์\nคุณยังสามารถสตรีมจากบริการคลาวด์ (Dropbox, OneDrive, Box) การเล่นระยะไกลจาก Mac หรือพีซีของคุณผ่านทาง UI เว็บ และการสตรีมผ่าน SMB, FTP, เซิร์ฟเวอร์สื่อ UPnP/DLNA และเว็บ\nVLC ยังรองรับคำบรรยายขั้นสูง รวมถึงเข้ากันได้กับ SSA แบบเต็ม, เสียงแบบมัลติแทรค, และการควบคุมความเร็วการเล่น\n\nVLC สำหรับ iOS นั้นฟรีอย่างสมบูรณ์และเป็นโอเพนซอร์ส\n\nข้อมูลเมตาและปกอัลบั้มอยู่ภายใต้เงื่อนไขโดย TMDb และ Hatchet ซึ่งรักษาไว้โดยชุมชนภาพยนตร์และฐานข้อมูลเพลง"; @@ -76,8 +76,8 @@ "BUTTON_RENDERER_HINT" = "แสดงเมนูอุปกรณ์การแคสต์ที่ใช้ได้"; -"BUTTON_PLAY_QUEUE" = "Play queue"; -"BUTTON_PLAY_QUEUE_HINT" = "Show the play queue view"; +"BUTTON_PLAY_QUEUE" = "คิวเล่น"; +"BUTTON_PLAY_QUEUE_HINT" = "แสดงมุมมองคิวเล่น"; "UPGRADING_LIBRARY" = "อัพเกรดคลังสื่อ"; @@ -85,7 +85,7 @@ "NETWORK_TITLE" = "สตรีมเครือข่าย"; "OPEN_NETWORK_HELP" = "ใส่ที่อยู่ HTTP, RTSP, RTMP, MMS, FTP หรือ UDP/RTP เพื่อเปิดการสตรีมโดยตรง"; "HTTP_UPLOAD_SERVER_OFF" = "เซิร์ฟเวอร์ไม่ตอบสนอง"; -"HTTP_UPLOAD_NO_CONNECTIVITY" = "No active Wi-Fi connection"; +"HTTP_UPLOAD_NO_CONNECTIVITY" = "ไม่มีการเชื่อมต่อ Wi-Fi ที่ใช้ได้"; "OPEN_STREAM_OR_DOWNLOAD" = "คุณต้องการดาวน์โหลดหรือเล่น URL นี้หรือไม่?"; "SHARED_VLC_IOS_LIBRARY" = "คลังสื่อ VLC สำหรับ iOS ที่มีการแชร์"; "SMB_CIFS_FILE_SERVERS" = "เซิร์ฟเวอร์ไฟล์ (SMB)"; @@ -115,7 +115,7 @@ "STREAMVC_DETAILTEXT" = "เล่นสตรีมโดยตรงโดยไม่ดาวน์โหลด"; "DOWNLOADVC_DETAILTEXT" = "ดาวน์โหลดไฟล์ลงในอุปกรณ์ของคุณโดยตรง"; -"HEADER_TITLE_RENDERER" = "Select a casting device"; +"HEADER_TITLE_RENDERER" = "เลือกอุปกรณ์การแคสต์"; "NETWORK" = "เครือข่าย"; "LOCAL_NETWORK" = "เครือข่ายท้องถิ่น"; @@ -147,7 +147,7 @@ "GDRIVE_ERROR_DOWNLOADING_FILE" = "เกิดข้อผิดพลาดขณะดาวน์โหลด"; "GDRIVE_ERROR_DOWNLOADING_FILE_TITLE" = "ปัญหา"; -"ONEDRIVE_MEDIA_WITHOUT_URL" = "The selected Media doesn't have a playable url"; +"ONEDRIVE_MEDIA_WITHOUT_URL" = "สื่อที่เลือกไม่มี URL ที่สามารถเล่นได้"; "DISK_FULL" = "ที่จัดเก็บข้อมูลเต็ม"; "DISK_FULL_FORMAT" = "%@ ไม่สามารถจัดเก็บบน %@ ของคุณได้เพราะคุณมีพื้นที่จัดเก็บคงเหลือไม่เพียงพอ"; @@ -160,8 +160,8 @@ "BIOMETRIC_UNLOCK" = "ปลดล็อกคลังสื่อ\nยกเลิกเพื่อใส่รหัสผ่าน"; //PAPasscode Strings that we need to localize for them -"%d Failed Passcode Attempts" = "%d Failed Passcode Attempts"; -"1 Failed Passcode Attempt" = "1 Failed Passcode Attempt"; +"%d Failed Passcode Attempts" = "ป้อนรหัสผ่านไม่สำเร็จ %d ครั้ง"; +"1 Failed Passcode Attempt" = "ป้อนรหัสผ่านไม่สำเร็จ 1 ครั้ง"; "Change Passcode" = "เปลี่ยนรหัสผ่าน"; "Enter Passcode" = "ป้อนรหัสผ่าน"; "Enter a passcode" = "ป้อนรหัสผ่าน"; @@ -179,10 +179,10 @@ "OFF" = "ปิด"; "EMPTY_LIBRARY" = "ไม่มีสื่อในคลัง"; -"EMPTY_LIBRARY_LONG" = "For playback, you can stream media from a server on your local network, from the cloud or synchronize media to your device using iTunes, Wi-Fi Upload or Cloud services."; +"EMPTY_LIBRARY_LONG" = "สำหรับการเล่น คุณสามารถสตรีมสื่อจากเซิร์ฟเวอร์บนเครือข่ายท้องถิ่นของคุณ จากคลาวด์ หรือซิงโครไนซ์สื่อไปยังอุปกรณ์ของคุณโดยใช้ iTunes, อัปโหลดผ่าน Wi-Fi หรือบริการคลาวด์ได้"; "EMPTY_PLAYLIST" = "เพลย์ลิสต์เปล่า"; -"EMPTY_PLAYLIST_DESCRIPTION" = "Add media while editing in the respective categories."; +"EMPTY_PLAYLIST_DESCRIPTION" = "เพิ่มสื่อขณะแก้ไขในหมวดหมู่ที่เรียงตามลำดับ"; "PLAYBACK_SCRUB_HELP" = "ไถลนิ้วของคุณลงเพื่อปรับอัตราการสครับบิง"; "PLAYBACK_SCRUB_HIGH" = "การสครับบิงความเร็วสูง"; @@ -215,12 +215,12 @@ "FIRST_STEPS_ITUNES" = "ซิงค์ไฟล์จาก iTunes"; "FIRST_STEPS_ITUNES_TITLE" = "ซิงค์กับคอมพิวเตอร์ของคุณ"; -"FIRST_STEPS_ITUNES_DETAILS" = "Connect your device to iTunes and select your device. Select \"File Sharing\" on the left side menu of iTunes and look for VLC to transfer files"; -"FIRST_STEPS_WIFI_TITLE" = "Share via Wi-Fi"; -"FIRST_STEPS_WIFI_DETAILS" = "Enter the generated URL in your favorite web browser while connected to the same network as your phone"; +"FIRST_STEPS_ITUNES_DETAILS" = "เชื่อมต่ออุปกรณ์ของคุณกับ iTunes แล้วเลือกอุปกรณ์ของคุณ เลือก \"การแชร์ไฟล์\" บนเมนูด้านซ้ายของ iTunes แล้วมองหา VLC เพื่อถ่ายโอนไฟล์"; +"FIRST_STEPS_WIFI_TITLE" = "แชร์ผ่าน Wi-Fi"; +"FIRST_STEPS_WIFI_DETAILS" = "ป้อน URL ที่สร้างขึ้นลงในเว็บเบราว์เซอร์โปรดของคุณขณะเชื่อมต่อกับเครือข่ายเดียวกับโทรศัพท์ของคุณ"; "FIRST_STEPS_CLOUDS" = "คลาวด์"; "FIRST_STEPS_CLOUD_TITLE" = "คลาวด์"; -"FIRST_STEPS_CLOUD_DETAILS" = "Upload your media to a cloud service like Google Drive or Dropbox to remotely download or stream them."; +"FIRST_STEPS_CLOUD_DETAILS" = "อัพโหลดสื่อของคุณไปยังบริการคลาวด์ เช่น Google ไดรฟ์ หรือ Dropbox เพื่อดาวน์โหลดหรือสตรีมจากระยะไก"; "PLEX_CHECK_ACCOUNT" = "ตรวจสอบบัญชี Plex ของคุณใน การตั้งค่า"; @@ -233,7 +233,7 @@ "NO_SERVER_FOUND" = "ไม่พบเซิร์ฟเวอร์"; "NO_RECENT_STREAMS" = "ไม่มีการสตรีมถูกเล่นเมื่อเร็ว ๆ นี้"; -"WEBINTF_TITLE" = "Sharing via Wi-Fi"; +"WEBINTF_TITLE" = "การแชร์ผ่าน Wi-Fi"; "WEBINTF_DROPFILES" = "วางไฟล์"; "WEBINTF_DROPFILES_LONG" = "วางไฟล์ในหน้าต่างเพื่อเพิ่มมันลงไปใน %@ ของคุณ<br>หรือคลิกที่ปุ่ม \"+\" เพื่อใช้กล่องโต้ตอบไฟล์"; "WEBINTF_DOWNLOADFILES" = "ดาวน์โหลดไฟล์"; @@ -243,9 +243,9 @@ "WEBINTF_URL_SENT" = "ส่ง URL สำเร็จ"; "WEBINTF_URL_EMPTY" = "URL ไม่สามารถปล่อยว่างได้"; "WEBINTF_URL_INVALID" = "URL ไม่ถูกต้อง"; -"WEBINTF_AUTH_REQUIRED" = "Please enter the passcode you set in VLC iOS:"; -"WEBINTF_AUTH_WRONG_PASSCODE" = "Wrong passcode.<br>Remaining attempts: "; -"WEBINTF_AUTH_BANNED" = "You entered too many wrong passcodes.<br>Please restart VLC iOS and try again."; +"WEBINTF_AUTH_REQUIRED" = "โปรดป้อนรหัสผ่านที่คุณตั้งใน VLC iOS:"; +"WEBINTF_AUTH_WRONG_PASSCODE" = "รหัสผ่านไม่ถูกต้อง<br>จำนวนครั้งที่สามารถลองได้อีก: "; +"WEBINTF_AUTH_BANNED" = "คุณป้อนรหัสผ่านไม่ถูกต้องหลายครั้งจนมากเกินไป<br>โปรดเปิ VLC iOS ใหม่แล้วลองอีกครั้ง"; @@ -299,8 +299,8 @@ "DELETE_ITEM_HINT" = "กด %@ เพื่อลบ"; /* Insert %@ where play-pause-glyph should be placed */ "DELETE_MESSAGE" = "ยืนยันการลบส่วนที่เลือก"; -"DELETE_MESSAGE_PLAYLIST" = "Are you sure to delete the selected playlist?\nAssociated media files won't be deleted."; -"DELETE_MESSAGE_PLAYLIST_CONTENT" = "Are you sure to remove the selected media from the playlist?\nThey won't be deleted from the disk."; +"DELETE_MESSAGE_PLAYLIST" = "คุณแน่ใจหรือไม่ว่าต้องการลบเพลย์ลิสต์ที่เลือก?\nไฟล์สื่อที่สัมพันธ์กันจะไม่ถูกลบ"; +"DELETE_MESSAGE_PLAYLIST_CONTENT" = "คุณแน่ใจหรือไม่ว่าต้องการเอาสื่อที่เลือกออกจากเพลย์ลิสต์?\nสื่อจะไม่ถูกลบออกจากดิสก์"; "DELETE_TITLE" = "ลบส่วนที่เลือก"; //Drag and Drop @@ -323,7 +323,7 @@ "ARTISTS" = "ศิลปิน"; "EPISODES" = "ตอน"; "GENRES" = "ประเภท"; -"ALL_VIDEOS" = "All videos"; +"ALL_VIDEOS" = "วิดีโอทั้งหมด"; "SONGS" = "เพลง"; "PLAYLISTS" = "เพลย์ลิสต์"; "VIDEO_GROUPS" = "กลุ่มวิดีโอ"; @@ -337,14 +337,14 @@ "BUTTON_EDIT_HINT" = "โหมดการแก้ไข"; "ADD_TO_PLAYLIST" = "เพิ่มลงในเพลย์ลิสต์"; -"ADD_TO_PLAYLIST_HINT" = "Open the add to playlist menu"; +"ADD_TO_PLAYLIST_HINT" = "เปิดเมนู 'เพิ่มลงในเพลย์ลิสต์'"; "PLAYLIST_PLACEHOLDER" = "ชื่อเรื่องเพลย์ลิสต์"; -"PLAYLIST_DESCRIPTION" = "Choose a title for your new playlist"; +"PLAYLIST_DESCRIPTION" = "เลือกชื่อเรื่องให้กับเพลย์ลิสต์ใหม่ของคุณ"; "PLAYLIST_CREATION" = "สร้างเพลย์ลิสต์ใหม่"; -"PLAYLIST_CREATION_HINT" = "Show an interactive action to create a playlist"; -"ERROR_PLAYLIST_CREATION" = "Failed to create a playlist"; -"ERROR_PLAYLIST_TRACKS" = "Failed to retrieve tracks"; +"PLAYLIST_CREATION_HINT" = "แสดงการกระทำแบบโต้ตอบเพื่อสร้างเพลย์ลิสต์"; +"ERROR_PLAYLIST_CREATION" = "ไม่สามารถสร้างเพลย์ลิสต์ได้"; +"ERROR_PLAYLIST_TRACKS" = "ไม่สามารถดึงข้อมูลแทร็กได"; "ERROR_RENAME_FAILED" = "การเปลี่ยนชื่อล้มเหลว"; "ERROR_EMPTY_NAME" = "ชื่อเรื่องต้องไม่ว่างเปล่า"; @@ -356,34 +356,34 @@ // Sort -"BUTTON_SORT" = "Sort"; -"BUTTON_SORT_HINT" = "Display sort action sheet"; +"BUTTON_SORT" = "เรียงลำดับ"; +"BUTTON_SORT_HINT" = "แสดงแผ่นการกระทำเรียงลำดับ"; "HEADER_TITLE_SORT" = "จัดเรียงตาม"; -"DESCENDING_LABEL" = "Descending Order"; -"DESCENDING_SWITCH_LABEL" = "Ascending or descending order"; -"DESCENDING_SWITCH_HINT" = "Sort context in ascending or descending order"; -"GRID_LAYOUT" = "Grid Layout"; +"DESCENDING_LABEL" = "จากมากไปหาน้อย"; +"DESCENDING_SWITCH_LABEL" = "จากน้อยไปหามาก หรือจากมากไปหาน้อย"; +"DESCENDING_SWITCH_HINT" = "เรียงลำดับบริบทจากน้อยไปหามาก หรือจากมากไปหาน้อย"; +"GRID_LAYOUT" = "เค้าโครงเส้นตาราง"; // VLCMediaLibraryKit - Sorting Criteria "ALPHA" = "ตามลำดับตัวอักษร"; "DURATION" = "ระยะเวลา"; "INSERTION_DATE" = "วันที่แทรก"; -"LAST_MODIFICATION_DATE" = "Last modification date"; -"RELEASE_DATE" = "Release date"; +"LAST_MODIFICATION_DATE" = "วันที่ปรับเปลี่ยนล่าสุด"; +"RELEASE_DATE" = "วันที่ปล่อย"; "FILE_SIZE" = "ขนาดไฟล์"; "ARTIST" = "ศิลปิน"; "PLAY_COUNT" = "จำนวนการเล่น"; "ALBUM" = "อัลบั้ม"; "FILENAME" = "ชื่อไฟล์"; "TRACK_NUMBER" = "หมายเลขแทร็ก"; -"NB_AUDIO" = "Number of audio"; -"NB_MEDIA" = "Number of media"; -"NB_VIDEO" = "Number of video"; +"NB_AUDIO" = "จำนวนเสียง"; +"NB_MEDIA" = "จำนวนสื่อ"; +"NB_VIDEO" = "จำนวนวิดีโอ"; // VLCNetworkLoginTVViewController -"NO_SAVING_DATA" = "Nothing found"; +"NO_SAVING_DATA" = "ไม่พบรายการใด"; // MediaCollectionViewCell @@ -392,69 +392,69 @@ "UNKNOWN_ALBUM" = "ไม่ทราบอัลบั้ม"; /* VideoSubControl */ -"INTERFACE_LOCK_BUTTON" = "Lock interface"; -"INTERFACE_LOCK_HINT" = "Disable interface controls"; -"MORE_OPTIONS_BUTTON" = "More"; -"MORE_OPTIONS_HINT" = "View more option controls"; -"REPEAT_MODE_HINT" = "Change repeat mode of current item"; -"VIDEO_ASPECT_RATIO_HINT" = "Change the aspect ratio of the current video"; +"INTERFACE_LOCK_BUTTON" = "ล็อกอินเทอร์เฟซ"; +"INTERFACE_LOCK_HINT" = "ิปิดใช้งานการควบคุมอินเทอร์เฟซ"; +"MORE_OPTIONS_BUTTON" = "เพิ่มเติม"; +"MORE_OPTIONS_HINT" = "ดูการควบคุมตัวเลือกเพิ่มเติม"; +"REPEAT_MODE_HINT" = "เปลี่ยนโหมดเล่นซ้ำของรายการปัจจุบัน"; +"VIDEO_ASPECT_RATIO_HINT" = "เปลี่ยนอัตราส่วนภาพของวิดีโอปัจจุบั"; /* MediaMoreOptionsActionSheet */ -"EQUALIZER_CELL_TITLE" = "Equalizer"; -"MORE_OPTIONS_HEADER_TITLE" = "Video Options"; +"EQUALIZER_CELL_TITLE" = "อีควอไลเซอร์"; +"MORE_OPTIONS_HEADER_TITLE" = "ตัวเลือกวิดีโอ"; /* Settings - Force rescan alert */ -"FORCE_RESCAN_TITLE" = "Force media library rescan"; -"FORCE_RESCAN_MESSAGE" = "Do you want to force VLC to rescan your media library?\nIt could take some time."; +"FORCE_RESCAN_TITLE" = "บังคับให้สแกนคลังสื่อใหม่"; +"FORCE_RESCAN_MESSAGE" = "คุณต้องการบังคับให้ VLC สแกนคลังสื่อของคุณใหม่หรือไม่?\nการดำเนินการนี้อาจใช้เวลาสักครู"; // Local Network -"SMBV1_WARN_TITLE" = "SMBv1 Connection Warning"; -"SMBV1_WARN_DESCRIPTION" = "We detected an old protocol (SMBv1).\nAre you really sure to continue with SMBv1?\nWe advise upgrading or changing your server settings."; -"SMBV1_CONTINUE" = "Continue with SMBv1"; -"SMBV1_NEXT_PROTOCOL" = "Try SMBv2/v3"; +"SMBV1_WARN_TITLE" = "คำเตือนการเชื่อมต่อ SMBv1"; +"SMBV1_WARN_DESCRIPTION" = "เราตรวจพบโปรโตคอลแบบเก่า (SMBv1)\nคุณแน่ใจหรือไม่ว่าต้องการใช้ SMBv1 ต่อ?\nเราขอแนะนำให้อัปเกรดหรือเปลี่ยนการตั้งค่าเซิร์ฟเวอร์ของคุณ"; +"SMBV1_CONTINUE" = "ใช้ SMBv1 ต่อ"; +"SMBV1_NEXT_PROTOCOL" = "ลองใช้ SMBv2/v3"; /* Preview labels */ -"ENCODING" = "Encoding"; +"ENCODING" = "การเข้ารหัส"; /* Media groups */ -"ADD_TO_MEDIA_GROUP" = "Add to media group"; -"ADD_TO_MEDIA_GROUP_HINT" = "Open the add to media group menu"; +"ADD_TO_MEDIA_GROUP" = "เพิ่มลงในกลุ่มสื่อ"; +"ADD_TO_MEDIA_GROUP_HINT" = "เปิดเมนู 'เพิ่มลงในกลุ่มสื่อ'"; -"MEDIA_GROUPS" = "Media groups"; -"MEDIA_GROUPS_DESCRIPTION" = "Choose a title for your new media group"; -"MEDIA_GROUPS_PLACEHOLDER" = "Media group title"; +"MEDIA_GROUPS" = "กลุ่มสื่อ"; +"MEDIA_GROUPS_DESCRIPTION" = "เลือกชื่อเรื่องสำหรับกลุ่มสื่อใหม่ของคุณ"; +"MEDIA_GROUPS_PLACEHOLDER" = "ชื่อเรื่องกลุ่มสื่อ"; -"REMOVE_FROM_MEDIA_GROUP" = "Remove from media group"; -"REMOVE_FROM_MEDIA_GROUP_HINT" = "Remove selection from the media group"; +"REMOVE_FROM_MEDIA_GROUP" = "เอาออกจากกลุ่มสื่อ"; +"REMOVE_FROM_MEDIA_GROUP_HINT" = "เอารายการที่เลือกออกจากกลุ่มสื่อ"; -"MEDIA_GROUP_CREATION" = "New media group"; -"MEDIA_GROUP_CREATION_HINT" = "Show alert to create a playlist"; -"MEDIA_GROUP_MOVE_TO_ROOT" = "Move content to top level"; -"MEDIA_GROUP_MOVE_TO_ROOT_HINT" = "Moves the content of the selection to the top level"; +"MEDIA_GROUP_CREATION" = "กลุ่มสื่อใหม่"; +"MEDIA_GROUP_CREATION_HINT" = "แสดงการแจ้งเตือนให้สร้างเพลย์ลิสต์"; +"MEDIA_GROUP_MOVE_TO_ROOT" = "ย้ายเนื้อหาไปยังระดับบนสุด"; +"MEDIA_GROUP_MOVE_TO_ROOT_HINT" = "ย้ายเนื้อหาของรายการที่เลือกไปยังระดับบนสุด"; -"BUTTON_REGROUP" = "Regroup"; -"BUTTON_REGROUP_TITLE" = "Regroup selection"; -"BUTTON_REGROUP_HINT" = "Attempt to regroup automatically single media."; -"BUTTON_REGROUP_DESCRIPTION" = "Are you sure to attempt to regroup automatically single media?\nThis can take some time."; +"BUTTON_REGROUP" = "จัดกลุ่มใหม่"; +"BUTTON_REGROUP_TITLE" = "จัดกลุ่มรายการที่เลือกใหม่"; +"BUTTON_REGROUP_HINT" = "พยายามจัดกลุ่มสื่อเดี่ยวใหม่โดยอัตโนมัติ"; +"BUTTON_REGROUP_DESCRIPTION" = "คุณแน่ใจหรือไม่ว่าต้องการพยายามจัดกลุ่มสื่อเดี่ยวใหม่โดยอัตโนมัติ?\nการดำเนินการนี้อาจใช้เวลาสักครู่"; /* Files.app persistence file */ -"MEDIALIBRARY_FILES_PLACEHOLDER" = "Place media here to add them"; -"MEDIALIBRARY_ADDING_PLACEHOLDER" = "Adding..."; +"MEDIALIBRARY_FILES_PLACEHOLDER" = "วางสื่อที่นี่เพื่อเพิ่ม"; +"MEDIALIBRARY_ADDING_PLACEHOLDER" = "กำลังเพิ่ม..."; /* tip jar */ -"GIVE_TIP" = "Give a Tip"; -"CANNOT_MAKE_PAYMENTS" = "You are not allowed to make payments on this device."; -"PURCHASE_FAILED" = "Purchase Failed"; -"SEND_GIFT" = "Send your gift"; +"GIVE_TIP" = "มอบทิป"; +"CANNOT_MAKE_PAYMENTS" = "คุณไม่ได้รับอนุญาตให้ทำการชำระเงินบนอุปกรณ์นี้"; +"PURCHASE_FAILED" = "การสั่งซื้อล้มเหลว"; +"SEND_GIFT" = "ส่งของขวัญของคุณ"; // MARK: - QueueViewController -"PLAY_HINT" = "Play"; -"PLAY_LABEL" = "Play"; -"PLAY_NEXT_IN_QUEUE_HINT" = "Play next in queue"; -"PLAY_NEXT_IN_QUEUE_LABEL" = "Play next in queue"; -"APPEND_TO_QUEUE_HINT" = "Append to queue"; -"APPEND_TO_QUEUE_LABEL" = "Append to queue"; +"PLAY_HINT" = "เล่น"; +"PLAY_LABEL" = "เล่น"; +"PLAY_NEXT_IN_QUEUE_HINT" = "เล่นรายการถัดไปในคิว"; +"PLAY_NEXT_IN_QUEUE_LABEL" = "เล่นรายการถัดไปในคิว"; +"APPEND_TO_QUEUE_HINT" = "ผนวกไปยังคิว"; +"APPEND_TO_QUEUE_LABEL" = "ผนวกไปยังคิว";
0
7dd9d06156134d9e508d1fdf3de3d5e4bd1b515c
https://github.com/bigtreecms/BigTree-CMS/commit/7dd9d06156134d9e508d1fdf3de3d5e4bd1b515c
Turning on auto detect line endings for CSV parsing
diff --git a/core/admin/modules/dashboard/vitals-statistics/404/import-csv.php b/core/admin/modules/dashboard/vitals-statistics/404/import-csv.php index 87469ba18..18d497bba 100644 --- a/core/admin/modules/dashboard/vitals-statistics/404/import-csv.php +++ b/core/admin/modules/dashboard/vitals-statistics/404/import-csv.php @@ -1,4 +1,6 @@ <?php + ini_set("auto_detect_line_endings", true); + if (empty($_FILES["csv"]["tmp_name"])) { $error = "The CSV file failed to upload. Please try again."; } else { diff --git a/core/admin/modules/dashboard/vitals-statistics/404/process-csv.php b/core/admin/modules/dashboard/vitals-statistics/404/process-csv.php index d5309a798..61f501ce9 100644 --- a/core/admin/modules/dashboard/vitals-statistics/404/process-csv.php +++ b/core/admin/modules/dashboard/vitals-statistics/404/process-csv.php @@ -3,6 +3,8 @@ BigTree::redirect(ADMIN_ROOT."dashboard/vitals-statistics/404/upload-csv/"); } + ini_set("auto_detect_line_endings", true); + $site_key = !empty($_POST["site_key"]) ? $_POST["site_key"] : null; $temp_file = fopen(SERVER_ROOT."cache/404-import.csv", "r"); $imported = [];
0
30b0025e19bd95ba28f4eff4d259671e7bb6bb86
https://github.com/thorsten/phpMyFAQ/commit/30b0025e19bd95ba28f4eff4d259671e7bb6bb86
Added some more protection against possible XSS attacks
diff --git a/phpmyfaq/admin/configuration.php b/phpmyfaq/admin/configuration.php index 68e94a9bda..e376a8002f 100644 --- a/phpmyfaq/admin/configuration.php +++ b/phpmyfaq/admin/configuration.php @@ -46,7 +46,12 @@ // Set the new values $forbiddenValues = ['{', '}', '$']; $newConfigValues = []; - $escapeValues = ['main.contactInformations', 'main.customPdfHeader', 'main.customPdfFooter']; + $escapeValues = [ + 'main.contactInformations', + 'main.customPdfHeader', + 'main.customPdfFooter', + 'main.titleFAQ' + ]; // Special checks if (isset($editData['edit']['main.enableMarkdownEditor'])) { @@ -58,7 +63,7 @@ $newConfigValues[$key] = str_replace($forbiddenValues, '', $value); // Escape some values if (isset($escapeValues[$key])) { - $newConfigValues[$key] = PMF_String::htmlspecialchars($value, ENT_HTML5); + $newConfigValues[$key] = PMF_String::htmlspecialchars($value, ENT_QUOTES); } $keyArray = array_values(explode('.', $key)); $newConfigClass = array_shift($keyArray); diff --git a/phpmyfaq/inc/PMF/Faq.php b/phpmyfaq/inc/PMF/Faq.php index e2e7d3b019..5a29f3cd2c 100755 --- a/phpmyfaq/inc/PMF/Faq.php +++ b/phpmyfaq/inc/PMF/Faq.php @@ -1602,7 +1602,7 @@ public function getRecordTitle($id) if ($this->_config->getDb()->numRows($result) > 0) { while ($row = $this->_config->getDb()->fetchObject($result)) { - $question = $row->question; + $question = PMF_String::htmlspecialchars($row->question); } } else { $question = $this->pmf_lang['no_cats']; diff --git a/phpmyfaq/index.php b/phpmyfaq/index.php index 411f97212e..5aa75d71cb 100755 --- a/phpmyfaq/index.php +++ b/phpmyfaq/index.php @@ -479,11 +479,11 @@ $tplMainPage = array( 'msgLoginUser' => $user->isLoggedIn() ? $user->getUserData('display_name') : $PMF_LANG['msgLoginUser'], - 'title' => $faqConfig->get('main.titleFAQ').$title, + 'title' => PMF_String::htmlspecialchars($faqConfig->get('main.titleFAQ').$title), 'baseHref' => $faqSystem->getSystemUri($faqConfig), 'version' => $faqConfig->get('main.currentVersion'), - 'header' => str_replace('"', '', $faqConfig->get('main.titleFAQ')), - 'metaTitle' => str_replace('"', '', $faqConfig->get('main.titleFAQ').$title), + 'header' => PMF_String::htmlspecialchars(str_replace('"', '', $faqConfig->get('main.titleFAQ'))), + 'metaTitle' => PMF_String::htmlspecialchars(str_replace('"', '', $faqConfig->get('main.titleFAQ').$title)), 'metaDescription' => $metaDescription, 'metaKeywords' => $keywords, 'metaPublisher' => $faqConfig->get('main.metaPublisher'), diff --git a/phpmyfaq/main.php b/phpmyfaq/main.php index 302e2ff224..baf66c5b73 100755 --- a/phpmyfaq/main.php +++ b/phpmyfaq/main.php @@ -77,6 +77,6 @@ 'index', 'breadcrumb', [ - 'breadcrumbHeadline' => $faqConfig->get('main.titleFAQ') + 'breadcrumbHeadline' => PMF_String::htmlspecialchars($faqConfig->get('main.titleFAQ')) ] ); \ No newline at end of file
1
c3ad22234ef84d06d04d908b3c94c0d11df8afd
https://github.com/belaban/JGroups/commit/c3ad22234ef84d06d04d908b3c94c0d11df8afd
[JBPAPP-11251] Backport JGRP-2021 to EAP 5.2.
diff --git a/build.xml b/build.xml index 9cc77423b7c..f2ee5550c25 100644 --- a/build.xml +++ b/build.xml @@ -70,11 +70,13 @@ <patternset id="all.tests"> <include name="org/jgroups/tests/**Test**"/> <include name="org/jgroups/blocks/**Test**"/> + <include name="org/jgroups/protocols/**Test**"/> </patternset> <patternset id="junit.excludes"> <exclude name="**/DistributedQueueTest*"/> <exclude name="**/ChannelTestBase*"/> + <exclude name="**/EncryptTest*"/> </patternset> diff --git a/conf/asym-encrypt.xml b/conf/asym-encrypt.xml new file mode 100644 index 00000000000..6792a89db52 --- /dev/null +++ b/conf/asym-encrypt.xml @@ -0,0 +1,28 @@ + +<config> + <UDP mcast_recv_buf_size="64000" mcast_send_buf_size="32000" mcast_port="45566" ucast_recv_buf_size="64000" + use_incoming_packet_handler="false" mcast_addr="228.8.8.8" + loopback="true" ucast_send_buf_size="32000" ip_ttl="32"/> + <PING timeout="2000" num_initial_members="3"/> + <MERGE2 max_interval="10000" min_interval="5000"/> + <FD timeout="2000" max_tries="3" shun="true"/> + <VERIFY_SUSPECT timeout="1500"/> + + <!-- Asymmetric encryption using public/private encryption to fetch the shared secret key --> + <ASYM_ENCRYPT + encrypt_entire_message="true" + sym_keylength="128" + sym_algorithm="AES/ECB/PKCS5Padding" + asym_keylength="512" + asym_algorithm="RSA"/> + + <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"/> + <UNICAST timeout="1200,2400,3600"/> + <pbcast.STABLE stability_delay="1000" desired_avg_gossip="20000" max_bytes="0"/> + <FRAG2 frag_size="8192" /> + <!-- AUTH below is required by ASYM_ENCRYPT --> + <AUTH auth_class="org.jgroups.auth.MD5Token" + auth_value="chris" + token_hash="MD5"/> + <pbcast.GMS print_local_addr="true" join_timeout="3000" shun="true"/> +</config> diff --git a/conf/jg-magic-map.xml b/conf/jg-magic-map.xml index 7460616ffe2..7701639d57e 100644 --- a/conf/jg-magic-map.xml +++ b/conf/jg-magic-map.xml @@ -42,4 +42,5 @@ <class id="66" name="org.jgroups.blocks.PullPushAdapter$PullHeader"/> <class id="67" name="org.jgroups.protocols.AuthHeader"/> <class id="68" name="org.jgroups.protocols.MERGE3$CoordAnnouncement"/> + <class id="69" name="org.jgroups.protocols.EncryptHeader"/> </magic-number-class-mapping> diff --git a/conf/sym-encrypt.xml b/conf/sym-encrypt.xml new file mode 100644 index 00000000000..62b7451b13c --- /dev/null +++ b/conf/sym-encrypt.xml @@ -0,0 +1,29 @@ + +<config> + <UDP mcast_recv_buf_size="64000" mcast_send_buf_size="32000" mcast_port="45566" ucast_recv_buf_size="64000" + use_incoming_packet_handler="false" mcast_addr="228.8.8.8" + loopback="true" ucast_send_buf_size="32000" ip_ttl="32"/> + <PING timeout="2000" num_initial_members="3"/> + <MERGE2 max_interval="10000" min_interval="5000"/> + <FD timeout="2000" max_tries="3" shun="true"/> + <VERIFY_SUSPECT timeout="1500"/> + + <!-- Symmetric encryption with a keystore --> + <SYM_ENCRYPT + provider="SunJCE" + sym_algorithm="AES" + encrypt_entire_message="true" + keystore_name="/home/bela/JGroups/keystore/defaultStore.keystore" + store_password="changeit" alias="myKey"/> + + + <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"/> + <UNICAST timeout="1200,2400,3600"/> + <pbcast.STABLE stability_delay="1000" desired_avg_gossip="20000" max_bytes="0"/> + <FRAG2 frag_size="8192" /> + <!-- AUTH below is optional --> + <AUTH auth_class="org.jgroups.auth.MD5Token" + auth_value="chris" + token_hash="MD5"/> + <pbcast.GMS print_local_addr="true" join_timeout="3000" shun="true"/> +</config> diff --git a/doc/design/MaliciousAttacks.txt b/doc/design/MaliciousAttacks.txt new file mode 100644 index 00000000000..c2528fb7326 --- /dev/null +++ b/doc/design/MaliciousAttacks.txt @@ -0,0 +1,91 @@ + +Use of encryption and authentication protocols to fend off malicious attacks +============================================================================ +Author: Bela Ban, April 2016 +JIRA: https://issues.jboss.org/browse/JGRP-2021 + +The following discussion refers to the changes made in JGroups 4.0. These have been backported to the 2.6 branch, but +the syntax looks different. However, the concepts are the same. + + + +Types of attacks handled +------------------------ +Malicious attacks essentially include (1) non-authorized nodes being able to join a cluster and (2) non-members being +able to communicate with cluster members. + +(1) is handled by AUTH which allows only authenticated nodes to join a cluster. + +(2) is handled by the encryption protocol (SYM_ENCRYPT or ASYM_ENCRYPT) which encrypts messages between cluster +members such that a non-member cannot understand them. + + + +Authentication +-------------- +Authentication is performed by AUTH. Its main use is to make sure only authenticated members can join a cluster. +Other scenarios where a check is performed are: +* Merging: make sure only authenticated members can merge into a new cluster +* View installation (if enabled): views and merge views can only be installed by authenticated members + +So authentication makes sure that rogue nodes will never be able to be members of a cluster, be it via joining or +merging. Note that while AUTH is optional with SYM_ENCRYPT, it is required by ASYM_ENCRYPT: there's a sanity check that +will prevent a member to start if ASYM_ENCRYPT is present but AUTH is absent. + + + +Authorization +------------- +There is currently no authorization in JGroups. Once a member is admitted to the cluster (via authentication), +it can send and receive messages to anyone. + + + +Encryption +---------- +This is based on a shared secret key that all members of a cluster have. The key is either acquired from a shared +keystore (symmetric encryption, below) or a new joiner fetches it from the coordinator via public/private key exchange +(asymmetric encryption, below). + +A sent message is encrypted with the shared secret key by the sender and decrypted with the same secret key by the +receiver(s). + +By default, the entire message (including the headers) is encrypted, but it is also possible to only encrypt the payload +(this is configurable). If the headers are not encrypted, it is possible to use replay attacks, because the +sequence numbers (seqnos) of a message are seen. For example, if a seqno is 50, then an attacker might copy the message, +and increment the seqno. This is prevented by copying and _signing_ the message. + +A message can be signed, which is a hash over the encrypted message, encrypted with the secret key. If the hash shipped +with a message doesn't match the hash computed over the received message, the message will be discarded by a receiver, +and no attempt is made to decrypt it. + +The cost of encrypting the entire message includes serializing the entire message (including headers, flags, destination +address etc) and encrypting it into the buffer of a new message (to the same destination). If message signing is enabled, +the cost of computing a hashcode and encrypting it is added to the above cost. + +Attributes present in both symmetric and asymmetric encryption include sign_msgs and encrypt_entire_message. + + +Symmetric encryption +-------------------- +This is done by SYM_ENCRYPT. The configuration includes mainly attributes that define the keystore, e.g. keystore_name +(name of the keystore, needs to be found on the classpath), store_password, key_password and alias. + + +Asymmetric encryption +--------------------- +Contrary to SYM_ENCRYPT, the secret key is not fetched from a shared keystore, but from the current coordinator C. After +new member P joined the cluster (passing the join check done by AUTH), P sends a request to get the secret key +(including P's public key) to C. + +C then sends the secret key back to P, encrypted with P's public key, and P decrypts it with its private key +and installs it. From then on, P encrypts and decrypts messages using the secret key. + +When a member leaves, C can optionally (based on change_key_on_leave) create a new secret key, and every cluster member +needs to fetch it again, using the public/private key exchange described above. + + + + + + diff --git a/src/org/jgroups/Message.java b/src/org/jgroups/Message.java index 94d1287437f..7223331920c 100644 --- a/src/org/jgroups/Message.java +++ b/src/org/jgroups/Message.java @@ -58,6 +58,7 @@ public static final byte OOB = 1; public static final byte LOW_PRIO = 2; // not yet sure if we want this flag... public static final byte HIGH_PRIO = 4; // not yet sure if we want this flag... + public static final byte NO_RELIABILITY = 8; private byte flags=0; @@ -357,6 +358,23 @@ public Message copy() { * @return Message with specified data */ public Message copy(boolean copy_buffer) { + return copy(copy_buffer, true); + } + + /** + * Create a copy of the message. If offset and length are used (to refer to another buffer), the + * copy will contain only the subset offset and length point to, copying the subset into the new + * copy.<p/> + * Note that for headers, only the arrays holding references to the headers are copied, not the headers themselves ! + * The consequence is that the headers array of the copy hold the *same* references as the original, so do *not* + * modify the headers ! If you want to change a header, copy it and call {@link Message#putHeader(short,Header)} again. + * + * @param copy_buffer + * @param copy_headers + * Copy the headers + * @return Message with specified data + */ + public Message copy(boolean copy_buffer, boolean copy_headers) { Message retval=new Message(false); retval.dest_addr=dest_addr; retval.src_addr=src_addr; @@ -368,11 +386,10 @@ public Message copy(boolean copy_buffer) { retval.setBuffer(buf, offset, length); } - retval.headers=createHeaders(headers); + retval.headers=copy_headers? createHeaders(headers) : createHeaders(3); return retval; } - protected Object clone() throws CloneNotSupportedException { return copy(); } @@ -675,6 +692,13 @@ private String flagsToString() { first=false; sb.append("HIGH_PRIO"); } + if(isFlagSet(NO_RELIABILITY)) { + if(!first) + sb.append("|"); + else + first=false; + sb.append("NO_RELIABILITY"); + } return sb.toString(); } diff --git a/src/org/jgroups/View.java b/src/org/jgroups/View.java index 196e76bd795..3eb6d4bb014 100644 --- a/src/org/jgroups/View.java +++ b/src/org/jgroups/View.java @@ -6,6 +6,7 @@ import org.jgroups.util.Util; import java.io.*; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Vector; @@ -72,7 +73,6 @@ public View(Address creator, long id, Vector<Address> members) { this(new ViewId(creator, id), members); } - /** * returns the view ID of this view * if this view was created with the empty constructur, null will be returned @@ -93,6 +93,8 @@ public Address getCreator() { return vid != null ? vid.getCoordAddress() : null; } + public Address getCoord() {return !members.isEmpty()? members.get(0) : null;} + /** * Returns a reference to the List of members (ordered) * Do NOT change this list, hence your will invalidate the view @@ -104,6 +106,13 @@ public Address getCreator() { return Util.unmodifiableVector(members); } + /** Returns the underlying list. The caller <em>must not</em> modify the contents. Should not be used by + * application code ! This method may be removed at any time, so don't use it ! + */ + public Vector<Address> getMembersRaw() { + return members; + } + /** * returns true, if this view contains a certain member * @@ -115,6 +124,16 @@ public boolean containsMember(Address mbr) { return !(mbr == null || members == null) && members.contains(mbr); } + public boolean containsMembers(Collection<Address> mbrs) { + if(mbrs == null || members == null) + return false; + for(Address mbr: mbrs) { + if(!containsMember(mbr)) + return false; + } + return true; + } + public boolean equals(Object obj) { if(!(obj instanceof View)) diff --git a/src/org/jgroups/auth/AuthToken.java b/src/org/jgroups/auth/AuthToken.java index 6199be99b9d..b9dc4bbb2f5 100644 --- a/src/org/jgroups/auth/AuthToken.java +++ b/src/org/jgroups/auth/AuthToken.java @@ -20,6 +20,11 @@ public void setAuth(AUTH auth) {this.auth=auth;} + public void init() throws Exception {} + public void start() throws Exception {} + public void stop() {} + public void destroy() {} + /** * Used to return the full package and class name of the implementation. This is used by the AUTH protocol to create an instance of the implementation. * @return a java.lang.String object of the package and class name diff --git a/src/org/jgroups/demos/KeyStoreGenerator.java b/src/org/jgroups/demos/KeyStoreGenerator.java index 53eda306326..f299982fcd0 100644 --- a/src/org/jgroups/demos/KeyStoreGenerator.java +++ b/src/org/jgroups/demos/KeyStoreGenerator.java @@ -5,6 +5,7 @@ import java.io.FileOutputStream; import java.io.OutputStream; import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; @@ -121,6 +122,17 @@ public static SecretKey initSymKey() throws Exception return secretKey; } + + public static SecretKey createSecretKey() throws Exception { + return createSecretKey(symAlg, keySize); + } + + public static SecretKey createSecretKey(String sym_alg, int key_size) throws NoSuchAlgorithmException { + // KeyGenerator keyGen=KeyGenerator.getInstance(getAlgorithm(sym_alg)); + KeyGenerator keyGen=KeyGenerator.getInstance(sym_alg); + keyGen.init(key_size); + return keyGen.generateKey(); + } private static String getAlgorithm(String s) { diff --git a/src/org/jgroups/protocols/ASYM_ENCRYPT.java b/src/org/jgroups/protocols/ASYM_ENCRYPT.java new file mode 100644 index 00000000000..b6d6dfb1a39 --- /dev/null +++ b/src/org/jgroups/protocols/ASYM_ENCRYPT.java @@ -0,0 +1,417 @@ +package org.jgroups.protocols; + +import org.jgroups.*; +import org.jgroups.conf.ClassConfigurator; +import org.jgroups.protocols.pbcast.GMS; +import org.jgroups.util.AsciiString; +import org.jgroups.util.Util; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.security.*; +import java.security.spec.X509EncodedKeySpec; +import java.util.Arrays; +import java.util.Properties; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +/** + * Encrypts and decrypts communication in JGroups by using a secret key distributed to all cluster members by the + * key server (coordinator) using asymmetric (public/private key) encryption.<br> + * + * The secret key is identical for all cluster members and is used to encrypt messages when sending and decrypt them + * when receiving messages. + * + * This protocol is typically placed under {@link org.jgroups.protocols.pbcast.NAKACK}, so that most important + * headers are encrypted as well, to prevent replay attacks.<br> + * + * The current keyserver (always the coordinator) generates a secret key. When a new member joins, it asks the keyserver + * for the secret key. The keyserver encrypts the secret key with the joiner's public key and the joiner decrypts it with + * its private key and then installs it and starts encrypting and decrypting messages with the secret key.<br> + * + * View changes that identify a new keyserver will result in a new secret key being generated and then distributed to + * all cluster members. This overhead can be substantial in an application with a reasonable member churn.<br> + * + * This protocol is suited to an application that does not ship with a known key but instead it is generated and + * distributed by the keyserver. + * + * Since messages can only get encrypted and decrypted when the secret key was received from the keyserver, messages + * other then join and merge requests/responses are dropped when the secret key isn't yet available. Join and merge + * requests / responses are handled by {@link AUTH}. + * + * @author Bela Ban + * @author Steve Woodcock + */ +public class ASYM_ENCRYPT extends EncryptBase { + + // When a member leaves the view, change the secret key, preventing old members from eavesdropping" + protected boolean change_key_on_leave=true; + protected volatile Address key_server_addr; + // True if this member is the current key server, false otherwise + protected volatile boolean is_key_server; + protected KeyPair key_pair; // to store own's public/private Key + protected Cipher asym_cipher; // decrypting cypher for secret key requests + // queue all up msgs until the secret key has been received/created + // whether or not to queue received messages (until the secret key was received) + protected volatile boolean queue_up_msgs=true; + // queues a bounded number of messages received during a null secret key (or fetching the key from a new coord) + protected final BlockingQueue<Message> up_queue=new ArrayBlockingQueue<Message>(100); + + protected volatile long last_key_request; + + public KeyPair getKeyPair() {return key_pair;} + public Cipher getAsymCipher() {return asym_cipher;} + public Address getKeyServerAddr() {return key_server_addr;} + public void setKeyServerAddr(Address key_srv) {this.key_server_addr=key_srv;} + + // Number of received messages currently queued + public int numQueuedMessages() {return up_queue.size();} + + public String getName() + { + return "ASYM_ENCRYPT"; + } + + public boolean setProperties(Properties props) + { + String str; + + super.setProperties(props); + + str=props.getProperty("change_key_on_leave"); + if(str != null) + { + change_key_on_leave=Boolean.valueOf(str).booleanValue(); + props.remove("change_key_on_leave"); + } + + if (!props.isEmpty()) + { + + if (log.isErrorEnabled()) + log.error("these properties are not recognized:" + props); + return false; + } + + return true; + } + + // Triggers a request for the secret key to the current keyserver + public void sendKeyRequest() { + if(key_server_addr == null) { + log.error(String.format("%s: key server is currently not set", local_addr)); + return; + } + sendKeyRequest(key_server_addr); + } + + public void init() throws Exception { + initKeyPair(); + super.init(); + } + + public void stop() { + drainUpQueue(); + super.stop(); + } + + public Object down(Event evt) { + if(evt.getType() == Event.MSG) { + Message msg=(Message)evt.getArg(); + if(skip(msg)) + return down_prot.down(evt); + } + return super.down(evt); + } + + public Object up(Event evt) { + if(evt.getType() == Event.MSG) { + Message msg=(Message)evt.getArg(); + if(skip(msg)) + return up_prot.up(evt); + } + return super.up(evt); + } + + + + /** Checks if a message needs to be encrypted/decrypted. Join and merge requests/responses don't need to be + * encrypted as they're authenticated by {@link AUTH} */ + protected static boolean skip(Message msg) { + GMS.GmsHeader hdr=(GMS.GmsHeader)msg.getHeader(GMS.name); + if(hdr == null) return false; + switch(hdr.getType()) { + case GMS.GmsHeader.JOIN_REQ: + case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER: + case GMS.GmsHeader.JOIN_RSP: + case GMS.GmsHeader.MERGE_REQ: + case GMS.GmsHeader.MERGE_RSP: + case GMS.GmsHeader.VIEW_ACK: + case GMS.GmsHeader.INSTALL_MERGE_VIEW: + return true; + } + return false; + } + + + @Override protected Object handleUpEvent(Message msg, EncryptHeader hdr) { + switch(hdr.getType()) { + case EncryptHeader.SECRET_KEY_REQ: + handleSecretKeyRequest(msg); + break; + case EncryptHeader.SECRET_KEY_RSP: + handleSecretKeyResponse(msg, hdr.getVersion()); + break; + default: + log.warn(String.format("%s: received unknown encrypt header of type %d", local_addr, hdr.getType())); + break; + } + return null; + } + + @Override protected boolean process(Message msg) { + if(queue_up_msgs || secret_key == null) { + up_queue.offer(msg); + log.trace(String.format("%s: queuing %s message from %s as secret key hasn't been retrieved from keyserver %s yet, hdrs: %s", + local_addr, msg.getDest() == null? "mcast" : "unicast", msg.getSrc(), key_server_addr, msg.printHeaders())); + if(last_key_request == 0 || System.currentTimeMillis() - last_key_request > 2000) { + last_key_request=System.currentTimeMillis(); + sendKeyRequest(); + } + return false; + } + return true; + } + + protected void handleSecretKeyRequest(final Message msg) { + if(!inView(msg.getSrc(), "%s: key requester %s is not in current view %s; ignoring key request")) + return; + log.debug(String.format("%s: received key request from %s", local_addr, msg.getSrc())); + try { + PublicKey tmpKey=generatePubKey(msg.getBuffer()); + sendSecretKey(secret_key, tmpKey, msg.getSrc()); + } + catch(Exception e) { + log.warn(String.format("%s: unable to reconstitute peer's public key", local_addr)); + } + } + + + protected void handleSecretKeyResponse(final Message msg, final byte[] key_version) { + if(!inView(msg.getSrc(), "%s: ignoring secret key sent by %s which is not in current view %s")) + return; + try { + SecretKey tmp=decodeKey(msg.getBuffer()); + if(tmp == null) + sendKeyRequest(key_server_addr); // unable to understand response, let's try again + else { + // otherwise set the returned key as the shared key + log.debug(String.format("%s: received secret key from keyserver %s", local_addr, msg.getSrc())); + setKeys(tmp, key_version); + } + } + catch(Exception e) { + log.warn(local_addr + ": unable to process received public key", e); + } + } + + + /** Initialise the symmetric key if none is supplied in a keystore */ + protected SecretKey createSecretKey() throws Exception { + KeyGenerator keyGen=null; + // see if we have a provider specified + if(provider != null && !provider.trim().isEmpty()) + keyGen=KeyGenerator.getInstance(getAlgorithm(sym_algorithm), provider); + else + keyGen=KeyGenerator.getInstance(getAlgorithm(sym_algorithm)); + // generate the key using the defined init properties + keyGen.init(sym_keylength); + return keyGen.generateKey(); + } + + + + /** Generates the public/private key pair from the init params */ + protected void initKeyPair() throws Exception { + // generate keys according to the specified algorithms + // generate publicKey and Private Key + KeyPairGenerator KpairGen=null; + if(provider != null && !provider.trim().isEmpty()) + KpairGen=KeyPairGenerator.getInstance(getAlgorithm(asym_algorithm), provider); + else + KpairGen=KeyPairGenerator.getInstance(getAlgorithm(asym_algorithm)); + KpairGen.initialize(asym_keylength,new SecureRandom()); + key_pair=KpairGen.generateKeyPair(); + + // set up the Cipher to decrypt secret key responses encrypted with our key + if(provider != null && !provider.trim().isEmpty()) + asym_cipher=Cipher.getInstance(asym_algorithm, provider); + else + asym_cipher=Cipher.getInstance(asym_algorithm); + asym_cipher.init(Cipher.DECRYPT_MODE, key_pair.getPrivate()); + } + + + @Override protected synchronized void handleView(View v) { + boolean left_mbrs=change_key_on_leave && this.view != null && !v.containsMembers(this.view.getMembersRaw()); + super.handleView(v); + + Address tmpKeyServer=v.getCoord(); // the coordinator is the keyserver + if(tmpKeyServer.equals(local_addr)) { + if(!is_key_server || left_mbrs) + becomeKeyServer(tmpKeyServer, left_mbrs); + } + else + handleNewKeyServer(tmpKeyServer, v instanceof MergeView, left_mbrs); + } + + + protected void becomeKeyServer(Address tmpKeyServer, boolean left_mbrs) { + if(log.isDebugEnabled()) { + if(!is_key_server) + log.debug(String.format("%s: I'm the new key server", local_addr)); + else if(left_mbrs) + log.debug(String.format("%s: creating new secret key because members left", local_addr)); + } + key_server_addr=tmpKeyServer; + is_key_server=true; + try { + this.secret_key=createSecretKey(); + initSymCiphers(sym_algorithm, secret_key); + drainUpQueue(); + } + catch(Exception ex) { + log.error(local_addr + ": failed creating secret key and initializing ciphers", ex); + } + } + + /** If the keyserver changed, send a request for the secret key to the keyserver */ + protected void handleNewKeyServer(Address newKeyServer, boolean merge_view, boolean left_mbrs) { + if(keyServerChanged(newKeyServer) || merge_view || left_mbrs) { + secret_key=null; + sym_version=null; + queue_up_msgs=true; + key_server_addr=newKeyServer; + is_key_server=false; + log.debug(String.format("%s: sending request for secret key to the new keyserver %s", local_addr, key_server_addr)); + sendKeyRequest(key_server_addr); + } + } + + protected boolean keyServerChanged(Address newKeyServer) { + return !equals(key_server_addr, newKeyServer); + } + + + + protected void setKeys(SecretKey key, byte[] version) throws Exception { + if(Arrays.equals(this.sym_version, version)) + return; + Cipher decoding_cipher=secret_key != null? decoding_ciphers.take() : null; + // put the previous key into the map, keep the cipher: no leak, as we'll clear decoding_ciphers in initSymCiphers() + if(decoding_cipher != null) + key_map.put(new AsciiString(version), decoding_cipher); + secret_key=key; + initSymCiphers(key.getAlgorithm(), key); + sym_version=version; + drainUpQueue(); + } + + + protected void sendSecretKey(SecretKey secret_key, PublicKey public_key, Address source) throws Exception { + byte[] encryptedKey=encryptSecretKey(secret_key, public_key); + Message newMsg=new Message(source, local_addr, encryptedKey); + newMsg.putHeader(getName(), new EncryptHeader(EncryptHeader.SECRET_KEY_RSP, getSymVersion())); + log.debug(String.format("%s: sending secret key to %s", local_addr, source)); + down_prot.down(new Event(Event.MSG,newMsg)); + } + + /** Encrypts the current secret key with the requester's public key (the requester will decrypt it with its private key) */ + protected byte[] encryptSecretKey(SecretKey secret_key, PublicKey public_key) throws Exception { + Cipher tmp; + if (provider != null && !provider.trim().isEmpty()) + tmp=Cipher.getInstance(asym_algorithm, provider); + else + tmp=Cipher.getInstance(asym_algorithm); + tmp.init(Cipher.ENCRYPT_MODE, public_key); + + // encrypt current secret key + return tmp.doFinal(secret_key.getEncoded()); + } + + + /** send client's public key to server and request server's public key */ + protected void sendKeyRequest(Address key_server) { + Message newMsg=new Message(key_server, local_addr, key_pair.getPublic().getEncoded()); + newMsg.putHeader(getName(),new EncryptHeader(EncryptHeader.SECRET_KEY_REQ, sym_version)); + down_prot.down(new Event(Event.MSG,newMsg)); + } + + + protected SecretKeySpec decodeKey(byte[] encodedKey) throws Exception { + byte[] keyBytes; + + synchronized(this) { + keyBytes=asym_cipher.doFinal(encodedKey); + } + + try { + SecretKeySpec keySpec=new SecretKeySpec(keyBytes, getAlgorithm(sym_algorithm)); + Cipher temp; + if (provider != null && !provider.trim().isEmpty()) + temp=Cipher.getInstance(sym_algorithm, provider); + else + temp=Cipher.getInstance(sym_algorithm); + temp.init(Cipher.SECRET_KEY, keySpec); + return keySpec; + } + catch(Exception e) { + log.error("Failed to decode key", e); + return null; + } + } + + // doesn't have to be 100% correct: leftover messages wll be delivered later and will be discarded as dupes, as + // retransmission is likely to have kicked in before anyway + protected void drainUpQueue() { + queue_up_msgs=false; + Message queued_msg; + while((queued_msg=up_queue.poll()) != null) { + try { + Message decrypted_msg=decryptMessage(null, queued_msg.copy()); + if(decrypted_msg != null) + up_prot.up(new Event(Event.MSG, decrypted_msg)); + } + catch(Exception ex) { + log.error(String.format("failed decrypting message from %s: %s", queued_msg.getSrc(), ex)); + } + } + } + + + @Override protected void handleUnknownVersion() { + if(!is_key_server) + sendKeyRequest(key_server_addr); + } + + /** Used to reconstitute public key sent in byte form from peer */ + protected PublicKey generatePubKey(byte[] encodedKey) { + PublicKey pubKey=null; + try { + KeyFactory KeyFac=KeyFactory.getInstance(getAlgorithm(asym_algorithm)); + X509EncodedKeySpec x509KeySpec=new X509EncodedKeySpec(encodedKey); + pubKey=KeyFac.generatePublic(x509KeySpec); + } + catch(Exception e) { + e.printStackTrace(); + } + return pubKey; + } + + protected static boolean equals(Object a, Object b) { + return (a == b) || (a != null && a.equals(b)); + } + +} diff --git a/src/org/jgroups/protocols/AUTH.java b/src/org/jgroups/protocols/AUTH.java index 220ca7d0fc1..924e3c83e0c 100644 --- a/src/org/jgroups/protocols/AUTH.java +++ b/src/org/jgroups/protocols/AUTH.java @@ -1,53 +1,95 @@ package org.jgroups.protocols; -import org.jgroups.Address; -import org.jgroups.Event; -import org.jgroups.Message; +import org.jgroups.*; import org.jgroups.auth.AuthToken; +import org.jgroups.conf.ClassConfigurator; import org.jgroups.protocols.pbcast.GMS; import org.jgroups.protocols.pbcast.JoinRsp; import org.jgroups.stack.Protocol; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; import java.util.Properties; /** - * The AUTH protocol adds a layer of authentication to JGroups + * The AUTH protocol adds a layer of authentication to JGroups. It intercepts join and merge requests and rejects them + * if the joiner or merger is not permitted to join a or merge into a cluster. AUTH should be placed right below + * {@link GMS} in the configuration. * @author Chris Mills + * @author Bela Ban */ -public class AUTH extends Protocol{ +public class AUTH extends Protocol { static final String NAME = "AUTH"; - /** - * used on the coordinator to authentication joining member requests against - */ - private AuthToken serverSideToken = null; + /** Interface to provide callbacks for handling up events */ + public interface UpHandler { + /** + * Called when an up event has been received + * @param evt the event + * @return true if the event should be passed up, else false + */ + boolean handleUpEvent(Event evt); + } + + + /** Used on the coordinator to authentication joining member requests against */ + protected AuthToken auth_token; + + /** List of UpHandler which are called when an up event has been received. Usually used by AuthToken impls */ + protected final List<UpHandler> up_handlers=new ArrayList<UpHandler>(); + + protected Address local_addr; + - public AUTH(){ + public AUTH() {} + + protected volatile boolean authenticate_coord=true; + + // Do join or merge responses from the coordinator also need to be authenticated + public void setAuthCoord( boolean authenticateCoord) { + this.authenticate_coord= authenticateCoord; } - public boolean setProperties(Properties props) { + public String getAuthClass() {return auth_token != null? auth_token.getClass().getName() : null;} + public AuthToken getAuthToken() {return auth_token;} + public void setAuthToken(AuthToken token) {this.auth_token=token;} + public void register(UpHandler handler) {up_handlers.add(handler);} + public void unregister(UpHandler handler) {up_handlers.remove(handler);} + public Address getAddress() {return local_addr;} - String authClassString = props.getProperty("auth_class"); - if(authClassString != null){ + public boolean setProperties(Properties props) { + String str; + + str = props.getProperty("auth_class"); + if(str != null){ props.remove("auth_class"); try{ - Object obj = Class.forName(authClassString).newInstance(); - serverSideToken = (AuthToken) obj; - serverSideToken.setAuth(this); - serverSideToken.setValue(props); + Object obj = Class.forName(str).newInstance(); + auth_token = (AuthToken) obj; + auth_token.setAuth(this); + auth_token.setValue(props); }catch(Exception e){ if(log.isFatalEnabled()){ - log.fatal("Failed to create server side token (" + authClassString + ")"); + log.fatal("Failed to create server side token (" + str + ")"); log.fatal(e); } return false; } } + str=props.getProperty("authenticate_coord"); + if(str != null) + { + authenticate_coord=Boolean.valueOf(str).booleanValue(); + props.remove("authenticate_coord"); + } + if(!props.isEmpty()) { //this should never happen as everything is read in to the AuthToken instance if(log.isErrorEnabled()){ @@ -61,146 +103,182 @@ public boolean setProperties(Properties props) { public final String getName() { return AUTH.NAME; } - /** - * Used to create a failed JOIN_RSP message to pass back down the stack - * @param joiner The Address of the requesting member - * @param message The failure message to send back to the joiner - * @return An Event containing a GmsHeader with a JoinRsp object - */ - private Event createFailureEvent(Address joiner, String message){ - Message msg = new Message(joiner, null, null); - if(log.isDebugEnabled()){ - log.debug("Creating JoinRsp with failure message - " + message); - } - JoinRsp joinRes = new JoinRsp(message); - //need to specify the error message on the JoinRsp object once it's been changed + public void init() throws Exception { + super.init(); + if(auth_token == null) + throw new IllegalStateException("no authentication mechanism configured"); + auth_token.init(); + } - GMS.GmsHeader gmsHeader = new GMS.GmsHeader(GMS.GmsHeader.JOIN_RSP, joinRes); - msg.putHeader(GMS.name, gmsHeader); + public void start() throws Exception { + super.start(); + if(auth_token != null) + auth_token.start(); + } - if(log.isDebugEnabled()){ - log.debug("GMSHeader created for failure JOIN_RSP"); - } + public void stop() { + if(auth_token != null) + auth_token.stop(); + super.stop(); + } - return new Event(Event.MSG, msg); + public void destroy() { + if(auth_token != null) + auth_token.destroy(); + super.destroy(); } /** - * An event was received from the layer below. Usually the current layer will want to examine - * the event type and - depending on its type - perform some computation - * (e.g. removing headers from a MSG event type, or updating the internal membership list - * when receiving a VIEW_CHANGE event). - * Finally the event is either a) discarded, or b) an event is sent down - * the stack using <code>down_prot.down()</code> or c) the event (or another event) is sent up - * the stack using <code>up_prot.up()</code>. + * An event was received from the layer below. Usually the current layer will want to examine the event type and + * - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating + * the internal membership list when receiving a VIEW_CHANGE event). + * Finally the event is either a) discarded, or b) an event is sent down the stack using {@code down_prot.down()} + * or c) the event (or another event) is sent up the stack using {@code up_prot.up()}. */ public Object up(Event evt) { - GMS.GmsHeader hdr = isJoinMessage(evt); - if((hdr != null) && (hdr.getType() == GMS.GmsHeader.JOIN_REQ || hdr.getType() == GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER)){ - if(log.isDebugEnabled()){ - log.debug("AUTH got up event"); - } - //we found a join message - now try and get the AUTH Header - Message msg = (Message)evt.getArg(); - - if((msg.getHeader(AUTH.NAME) != null) && (msg.getHeader(AUTH.NAME) instanceof AuthHeader)){ - AuthHeader authHeader = (AuthHeader)msg.getHeader(AUTH.NAME); - - if(authHeader != null){ - //Now we have the AUTH Header we need to validate it - if(this.serverSideToken.authenticate(authHeader.getToken(), msg)){ - //valid token - if(log.isDebugEnabled()){ - log.debug("AUTH passing up event"); - } - up_prot.up(evt); - }else{ - //invalid token - if(log.isWarnEnabled()){ - log.warn("AUTH failed to validate AuthHeader token"); - } - sendRejectionMessage(msg.getSrc(), createFailureEvent(msg.getSrc(), "Authentication failed")); - } - }else{ - //Invalid AUTH Header - need to send failure message - if(log.isWarnEnabled()){ - log.warn("AUTH failed to get valid AuthHeader from Message"); - } - sendRejectionMessage(msg.getSrc(), createFailureEvent(msg.getSrc(), "Failed to find valid AuthHeader in Message")); - } - }else{ - if(log.isDebugEnabled()){ - log.debug("No AUTH Header Found"); + switch(evt.getType()) { + case Event.MSG: + Message msg=(Message)evt.getArg(); + + // If we have a join or merge request --> authenticate, else pass up + GMS.GmsHeader gms_hdr=getGMSHeader(evt); + if(gms_hdr != null && needsAuthentication(gms_hdr)) { + AuthHeader auth_hdr=(AuthHeader)msg.getHeader(AUTH.NAME); + if(auth_hdr == null) + throw new IllegalStateException(String.format("found %s from %s but no AUTH header", gms_hdr, msg.getSrc())); + if(!handleAuthHeader(gms_hdr, auth_hdr, msg)) // authentication failed + return null; // don't pass up } - //should be a failure - sendRejectionMessage(msg.getSrc(), createFailureEvent(msg.getSrc(), "Failed to find an AuthHeader in Message")); - } - } else { - return up_prot.up(evt); + break; } - return null; + if(!callUpHandlers(evt)) + return null; + + return up_prot.up(evt); } - private void sendRejectionMessage(Address dest, Event join_rsp) { - if(dest == null) { - log.error("destination is null, cannot send JOIN rejection message to null destination"); - return; - } - down_prot.down(join_rsp); - } /** * An event is to be sent down the stack. The layer may want to examine its type and perform * some action on it, depending on the event's type. If the event is a message MSG, then * the layer may need to add a header to it (or do nothing at all) before sending it down - * the stack using <code>down_prot.down()</code>. In case of a GET_ADDRESS event (which tries to + * the stack using {@code down_prot.down()}. In case of a GET_ADDRESS event (which tries to * retrieve the stack's address from one of the bottom layers), the layer may need to send - * a new response event back up the stack using <code>up_prot.up()</code>. + * a new response event back up the stack using {@code up_prot.up()}. */ public Object down(Event evt) { - GMS.GmsHeader hdr = isJoinMessage(evt); - if((hdr != null) && (hdr.getType() == GMS.GmsHeader.JOIN_REQ || hdr.getType() == GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER)){ - if(log.isDebugEnabled()){ - log.debug("AUTH got down event"); - } - //we found a join request message - now add an AUTH Header - Message msg = (Message)evt.getArg(); - AuthHeader authHeader = new AuthHeader(); - authHeader.setToken(this.serverSideToken); - msg.putHeader(AUTH.NAME, authHeader); - - if(log.isDebugEnabled()){ - log.debug("AUTH passing down event"); - } + GMS.GmsHeader hdr = getGMSHeader(evt); + if(hdr != null && needsAuthentication(hdr)) { + // we found a join request message - now add an AUTH Header + Message msg=(Message)evt.getArg(); + msg.putHeader(AUTH.NAME, new AuthHeader(this.auth_token)); } - if((hdr != null) && (hdr.getType() == GMS.GmsHeader.JOIN_RSP)){ - if(log.isDebugEnabled()){ - log.debug(hdr.toString()); + if(evt.getType() == Event.SET_LOCAL_ADDRESS) + local_addr=(Address)evt.getArg(); + + return down_prot.down(evt); + } + + + + protected boolean needsAuthentication(GMS.GmsHeader hdr) { + switch(hdr.getType()) { + case GMS.GmsHeader.JOIN_REQ: + case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER: + case GMS.GmsHeader.MERGE_REQ: + return true; + case GMS.GmsHeader.JOIN_RSP: + case GMS.GmsHeader.MERGE_RSP: + case GMS.GmsHeader.INSTALL_MERGE_VIEW: + return this.authenticate_coord; + default: + return false; + } + } + + + /** + * Handles a GMS header + * @param gms_hdr + * @param msg + * @return true if the message should be passed up, or else false + */ + protected boolean handleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg) { + if(needsAuthentication(gms_hdr)) { + if(this.auth_token.authenticate(auth_hdr.getToken(), msg)) + return true; // authentication passed, send message up the stack + else { + log.warn(String.format("%s: failed to validate AuthHeader (token: %s) from %s; dropping message", + local_addr, auth_token.getClass().getSimpleName(), msg.getSrc())); + sendRejectionMessage(gms_hdr.getType(), msg.getSrc(), "authentication failed"); + return false; } } + return true; + } + + + protected void sendRejectionMessage(byte type, Address dest, String error_msg) { + switch(type) { + case GMS.GmsHeader.JOIN_REQ: + case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER: + sendJoinRejectionMessage(dest, error_msg); + break; + case GMS.GmsHeader.MERGE_REQ: + sendMergeRejectionMessage(dest); + break; + } + } - return down_prot.down(evt); + protected void sendJoinRejectionMessage(Address dest, String error_msg) { + if(dest == null) + return; + + JoinRsp joinRes=new JoinRsp(error_msg); // specify the error message on the JoinRsp + Message msg = new Message(dest); + msg.putHeader(GMS.name, new GMS.GmsHeader(GMS.GmsHeader.JOIN_RSP, joinRes)); + if(this.authenticate_coord) + msg.putHeader(AUTH.NAME, new AuthHeader(this.auth_token)); + down_prot.down(new Event(Event.MSG, msg)); + } + + protected void sendMergeRejectionMessage(Address dest) { + GMS.GmsHeader hdr=new GMS.GmsHeader(GMS.GmsHeader.MERGE_RSP); + hdr.setMergeRejected(true); + Message msg=new Message(dest); + msg.setFlag(Message.OOB); + msg.putHeader(GMS.name, hdr); + if(this.authenticate_coord) + msg.putHeader(AUTH.NAME, new AuthHeader(this.auth_token)); + log.debug("merge response=" + hdr); + down_prot.down(new Event(Event.MSG, msg)); + } + + protected boolean callUpHandlers(Event evt) { + boolean pass_up=true; + for(UpHandler handler: up_handlers) { + if(!handler.handleUpEvent(evt)) + pass_up=false; + } + return pass_up; } /** - * Used to check if the message type is a Gms message + * Get the header from a GMS message * @param evt The event object passed in to AUTH * @return A GmsHeader object or null if the event contains a message of a different type */ - private static GMS.GmsHeader isJoinMessage(Event evt){ - Message msg; - switch(evt.getType()){ - case Event.MSG: - msg = (Message)evt.getArg(); - Object obj = msg.getHeader("GMS"); - if(obj == null || !(obj instanceof GMS.GmsHeader)){ - return null; - } - return (GMS.GmsHeader)obj; - } + protected static GMS.GmsHeader getGMSHeader(Event evt){ + return evt.getType() == Event.MSG? getGMSHeader((Message)evt.getArg()) : null; + } + + protected static GMS.GmsHeader getGMSHeader(Message msg){ + Header hdr = msg.getHeader(GMS.name); + if(hdr instanceof GMS.GmsHeader) + return (GMS.GmsHeader)hdr; return null; } } diff --git a/src/org/jgroups/protocols/AuthHeader.java b/src/org/jgroups/protocols/AuthHeader.java index b75f5b20632..719e6f1bbdd 100644 --- a/src/org/jgroups/protocols/AuthHeader.java +++ b/src/org/jgroups/protocols/AuthHeader.java @@ -16,6 +16,11 @@ public AuthHeader(){ } + + public AuthHeader(AuthToken token) { + this.token=token; + } + /** * Sets the token value to that of the passed in token object * @param token the new authentication token diff --git a/src/org/jgroups/protocols/DISCARD.java b/src/org/jgroups/protocols/DISCARD.java index 50eaf1ac781..68b282bd4ae 100644 --- a/src/org/jgroups/protocols/DISCARD.java +++ b/src/org/jgroups/protocols/DISCARD.java @@ -42,6 +42,13 @@ protected boolean use_gui=false; + public boolean isDiscardAll() { + return discard_all; + } + + public void setDiscardAll(boolean discard_all) { + this.discard_all=discard_all; + } /** * All protocol names have to be unique ! diff --git a/src/org/jgroups/protocols/EncryptBase.java b/src/org/jgroups/protocols/EncryptBase.java new file mode 100644 index 00000000000..f76e7b01c7f --- /dev/null +++ b/src/org/jgroups/protocols/EncryptBase.java @@ -0,0 +1,464 @@ +package org.jgroups.protocols; + +import org.jgroups.*; +import org.jgroups.stack.Protocol; +import org.jgroups.util.*; + +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import java.security.MessageDigest; +import java.util.Arrays; +import java.util.Map; +import java.util.Properties; +import java.util.WeakHashMap; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.zip.Adler32; +import java.util.zip.CRC32; +import java.util.zip.Checksum; + +/** + * Super class of symmetric ({@link SYM_ENCRYPT}) and asymmetric ({@link ASYM_ENCRYPT}) encryption protocols. + * @author Bela Ban + */ +public abstract class EncryptBase extends Protocol { + protected static final String DEFAULT_SYM_ALGO="AES"; + + + /* ----------------------------------------- Properties -------------------------------------------------- */ + // Cryptographic Service Provider + protected String provider; + + // Cipher engine transformation for asymmetric algorithm. Default is RSA + protected String asym_algorithm="RSA"; + + // Cipher engine transformation for symmetric algorithm. Default is AES + protected String sym_algorithm=DEFAULT_SYM_ALGO; + + // Initial public/private key length. Default is 512 + protected int asym_keylength=512; + + // Initial key length for matching symmetric algorithm. Default is 128 + protected int sym_keylength=128; + + // Number of ciphers in the pool to parallelize encrypt and decrypt requests + protected int cipher_pool_size=8; + + // If true, the entire message (including payload and headers) is encrypted, else only the payload + protected boolean encrypt_entire_message=true; + + // If true, all messages are digitally signed by adding an encrypted checksum of the encrypted + // message to the header. Ignored if encrypt_entire_message is false + protected boolean sign_msgs=true; + + // When sign_msgs is true, by default CRC32 is used to create the checksum. If use_adler is + // true, Adler32 will be used + protected boolean use_adler; + + protected volatile Address local_addr; + + protected volatile View view; + + // Cipher pools used for encryption and decryption. Size is cipher_pool_size + protected BlockingQueue<Cipher> encoding_ciphers, decoding_ciphers; + + // version filed for secret key + protected volatile byte[] sym_version; + + // shared secret key to encrypt/decrypt messages + protected volatile SecretKey secret_key; + + // map to hold previous keys so we can decrypt some earlier messages if we need to + protected final Map<AsciiString,Cipher> key_map=new WeakHashMap<AsciiString,Cipher>(); + + public int getAsymKeylength() {return asym_keylength;} + public void setAsymKeylength(int len) {this.asym_keylength=len;} + public int getSymKeylength() {return sym_keylength;} + public void setSymKeylength(int len) {this.sym_keylength=len;} + public SecretKey getSecretKey() {return secret_key;} + public void setSecretKey(SecretKey key) {this.secret_key=key;} + public String getSymAlgorithm() {return sym_algorithm;} + public void setSymAlgorithm(String alg) {this.sym_algorithm=alg;} + public String getAsymAlgorithm() {return asym_algorithm;} + public void setAsymAlgorithm(String alg) {this.asym_algorithm=alg;} + public byte[] getSymVersion() {return sym_version;} + public void setSymVersion(byte[] v) {this.sym_version=Arrays.copyOf(v, v.length);} + public void setLocalAddress(Address addr) {this.local_addr=addr;} + public boolean getEncryptEntireMessage() {return encrypt_entire_message;} + public void setEncryptEntireMessage(boolean b) {this.encrypt_entire_message=b;} + public boolean getSignMessages() {return this.sign_msgs;} + public void setSignMessages(boolean flag) {this.sign_msgs=flag;} + public boolean getAdler() {return use_adler;} + public void setAdler(boolean flag) {this.use_adler=flag;} + public String getVersion() {return Util.byteArrayToHexString(sym_version);} + + public boolean setProperties(Properties props) + { + String str; + + super.setProperties(props); + + str = props.getProperty("provider"); + if (str != null) + { + provider = str; + props.remove("provider"); + + if (log.isInfoEnabled()) + log.info("Provider used is " + provider); + } + + // asymmetric algorithm name + str = props.getProperty("asym_algorithm"); + if (str != null) + { + asym_algorithm = str; + props.remove("asym_algorithm"); + + if (log.isInfoEnabled()) + log.info("Asym algo used is " + asym_algorithm); + } + + // symmetric algorithm name + str = props.getProperty("sym_algorithm"); + if (str != null) + { + sym_algorithm = str; + props.remove("sym_algorithm"); + + if (log.isInfoEnabled()) + log.info("Sym algo used is " + sym_algorithm); + } + + // asymmetric key length + str = props.getProperty("asym_keylength"); + if (str != null) + { + asym_keylength = Integer.parseInt(str); + props.remove("asym_keylength"); + + if (log.isInfoEnabled()) + log.info("Asym keylength used is " + asym_keylength); + } + + // asymmetric key length + str = props.getProperty("sym_keylength"); + if (str != null) + { + sym_keylength = Integer.parseInt(str); + props.remove("sym_keylength"); + + if (log.isInfoEnabled()) + log.info("Sym keylength used is " + sym_keylength); + } + + // cipher pool size + str = props.getProperty("cipher_pool_size"); + if (str != null) + { + cipher_pool_size = Integer.parseInt(str); + props.remove("cipher_pool_size"); + } + + str=props.getProperty("encrypt_entire_message"); + if(str != null) + { + encrypt_entire_message=Boolean.valueOf(str).booleanValue(); + props.remove("encrypt_entire_message"); + } + + str=props.getProperty("sign_msgs"); + if(str != null) + { + sign_msgs=Boolean.valueOf(str).booleanValue(); + props.remove("sign_msgs"); + } + + str=props.getProperty("use_adler"); + if(str != null) + { + use_adler=Boolean.valueOf(str).booleanValue(); + props.remove("use_adler"); + } + + return true; + } + + + public void init() throws Exception { + int tmp=Util.getNextHigherPowerOfTwo(cipher_pool_size); + if(tmp != cipher_pool_size) { + log.warn(String.format("%s: setting cipher_pool_size (%d) to %d (power of 2) for faster modulo operation", local_addr, cipher_pool_size, tmp)); + cipher_pool_size=tmp; + } + encoding_ciphers=new ArrayBlockingQueue<Cipher>(cipher_pool_size); + decoding_ciphers=new ArrayBlockingQueue<Cipher>(cipher_pool_size); + initSymCiphers(sym_algorithm, secret_key); + } + + + public Object down(Event evt) { + switch(evt.getType()) { + case Event.MSG: + Message msg=(Message)evt.getArg(); + try { + if(secret_key == null) { + log.trace(String.format("%s: discarded %s message to %s as secret key is null, hdrs: %s", + local_addr, msg.getDest() == null? "mcast" : "unicast", msg.getDest(), msg.printHeaders())); + return null; + } + encryptAndSend(msg); + } + catch(Exception e) { + log.warn(local_addr + ": unable to send message down", e); + } + return null; + + case Event.VIEW_CHANGE: + handleView((View)evt.getArg()); + break; + } + return down_prot.down(evt); + } + + + public Object up(Event evt) { + switch(evt.getType()) { + case Event.VIEW_CHANGE: + handleView((View)evt.getArg()); + break; + case Event.SET_LOCAL_ADDRESS: + local_addr=(Address)evt.getArg(); + break; + case Event.MSG: + Message msg=(Message)evt.getArg(); + try { + return handleUpMessage(msg); + } + catch(Exception e) { + log.warn(local_addr + ": exception occurred decrypting message", e); + } + return null; + } + return up_prot.up(evt); + } + + + + + /** Initialises the ciphers for both encryption and decryption using the generated or supplied secret key */ + protected synchronized void initSymCiphers(String algorithm, SecretKey secret) throws Exception { + if(secret == null) + return; + encoding_ciphers.clear(); + decoding_ciphers.clear(); + for(int i=0; i < cipher_pool_size; i++ ) { + encoding_ciphers.add(createCipher(Cipher.ENCRYPT_MODE, secret, algorithm)); + decoding_ciphers.add(createCipher(Cipher.DECRYPT_MODE, secret, algorithm)); + }; + + //set the version + MessageDigest digest=MessageDigest.getInstance("MD5"); + digest.reset(); + digest.update(secret.getEncoded()); + + byte[] tmp=digest.digest(); + sym_version=Arrays.copyOf(tmp, tmp.length); + log.debug(String.format("%s: created %d symmetric ciphers with secret key (%d bytes)", local_addr, cipher_pool_size, sym_version.length)); + } + + + protected Cipher createCipher(int mode, SecretKey secret_key, String algorithm) throws Exception { + Cipher cipher=provider != null && !provider.trim().isEmpty()? + Cipher.getInstance(algorithm, provider) : Cipher.getInstance(algorithm); + cipher.init(mode, secret_key); + return cipher; + } + + + protected Object handleUpMessage(Message msg) throws Exception { + EncryptHeader hdr=(EncryptHeader)msg.getHeader(getName()); + if(hdr == null) { + log.error(String.format("%s: received message without encrypt header from %s; dropping it", local_addr, msg.getSrc())); + return null; + } + switch(hdr.getType()) { + case EncryptHeader.ENCRYPT: + return handleEncryptedMessage(msg); + default: + return handleUpEvent(msg,hdr); + } + } + + + protected Object handleEncryptedMessage(Message msg) throws Exception { + if(!process(msg)) + return null; + + // try and decrypt the message - we need to copy msg as we modify its + // buffer (http://jira.jboss.com/jira/browse/JGRP-538) + Message tmpMsg=decryptMessage(null, msg.copy()); // need to copy for possible xmits + if(tmpMsg != null) + return up_prot.up(new Event(Event.MSG, tmpMsg)); + log.warn(String.format("%s: unrecognized cipher; discarding message from %s", local_addr, msg.getSrc())); + return null; + } + + protected Object handleUpEvent(Message msg, EncryptHeader hdr) { + return null; + } + + /** Whether or not to process this received message */ + protected boolean process(Message msg) {return true;} + + protected void handleView(View view) { + this.view=view; + } + + protected boolean inView(Address sender, String error_msg) { + View curr_view=this.view; + if(curr_view == null || curr_view.containsMember(sender)) + return true; + log.error(String.format(error_msg, local_addr, sender, curr_view)); + return false; + } + + protected Checksum createChecksummer() {return use_adler? new Adler32() : new CRC32();} + + + /** Does the actual work for decrypting - if version does not match current cipher then tries the previous cipher */ + protected Message decryptMessage(Cipher cipher, Message msg) throws Exception { + EncryptHeader hdr=(EncryptHeader)msg.getHeader(getName()); + if(hdr.getVersion() == null) + return null; + if(!Arrays.equals(hdr.getVersion(), sym_version)) { + cipher=key_map.get(new AsciiString(hdr.getVersion())); + if(cipher == null) { + handleUnknownVersion(); + return null; + } + log.trace(String.format("%s: decrypting msg from %s using previous cipher version", local_addr, msg.getSrc())); + return _decrypt(cipher, msg, hdr); + } + return _decrypt(cipher, msg, hdr); + } + + protected Message _decrypt(final Cipher cipher, Message msg, EncryptHeader hdr) throws Exception { + byte[] decrypted_msg; + + if(!encrypt_entire_message && msg.getLength() == 0) + return msg; + + if(encrypt_entire_message && sign_msgs) { + byte[] signature=hdr.getSignature(); + if(signature == null) { + log.error(String.format("%s: dropped message from %s as the header did not have a checksum", local_addr, msg.getSrc())); + return null; + } + + long msg_checksum=decryptChecksum(cipher, signature, 0, signature.length); + long actual_checksum=computeChecksum(msg.getRawBuffer(), msg.getOffset(), msg.getLength()); + if(actual_checksum != msg_checksum) { + log.error(String.format("%s: dropped message from %s as the message's checksum (%d) did not match the computed checksum (%d)", + local_addr, msg.getSrc(), msg_checksum, actual_checksum)); + return null; + } + } + + if(cipher == null) + decrypted_msg=code(msg.getRawBuffer(), msg.getOffset(), msg.getLength(), true); + else + decrypted_msg=cipher.doFinal(msg.getRawBuffer(), msg.getOffset(), msg.getLength()); + + if(!encrypt_entire_message) { + msg.setBuffer(decrypted_msg); + return msg; + } + + Message ret=(Message)Util.streamableFromByteBuffer(Message.class,decrypted_msg,0,decrypted_msg.length); + if(ret.getDest() == null) + ret.setDest(msg.getDest()); + if(ret.getSrc() == null) + ret.setSrc(msg.getSrc()); + return ret; + } + + + protected void encryptAndSend(Message msg) throws Exception { + EncryptHeader hdr=new EncryptHeader(EncryptHeader.ENCRYPT, getSymVersion()); + if(encrypt_entire_message) { + if(msg.getSrc() == null) + msg.setSrc(local_addr); + + byte [] serialized_msg=Util.streamableToByteBuffer(msg); + byte[] encrypted_msg=code(serialized_msg,0,serialized_msg.length,false); + + if(sign_msgs) { + long checksum=computeChecksum(encrypted_msg, 0, encrypted_msg.length); + byte[] checksum_array=encryptChecksum(checksum); + hdr.setSignature(checksum_array); + } + + // exclude existing headers, they will be seen again when we decrypt and unmarshal the msg at the receiver + Message tmp=msg.copy(false, false); + tmp.setBuffer(encrypted_msg); + tmp.putHeader(getName(),hdr); + down_prot.down(new Event(Event.MSG, tmp)); + return; + } + + // copy neeeded because same message (object) may be retransmitted -> prevent double encryption + Message msgEncrypted=msg.copy(false); + msgEncrypted.putHeader(getName(), hdr); + if(msg.getLength() > 0) + msgEncrypted.setBuffer(code(msg.getRawBuffer(),msg.getOffset(),msg.getLength(),false)); + down_prot.down(new Event(Event.MSG,msgEncrypted)); + } + + + protected byte[] code(byte[] buf, int offset, int length, boolean decode) throws Exception { + BlockingQueue<Cipher> queue=decode? decoding_ciphers : encoding_ciphers; + Cipher cipher=queue.take(); + try { + return cipher.doFinal(buf, offset, length); + } + finally { + queue.offer(cipher); + } + } + + protected long computeChecksum(byte[] input, int offset, int length) { + Checksum checksummer=createChecksummer(); + checksummer.update(input, offset, length); + return checksummer.getValue(); + } + + protected byte[] encryptChecksum(long checksum) throws Exception { + byte[] checksum_array=new byte[Global.LONG_SIZE]; + Bits.writeLong(checksum, checksum_array, 0); + return code(checksum_array, 0, checksum_array.length, false); + } + + protected long decryptChecksum(final Cipher cipher, byte[] input, int offset, int length) throws Exception { + byte[] decrypted_checksum; + if(cipher == null) + decrypted_checksum=code(input, offset, length, true); + else + decrypted_checksum=cipher.doFinal(input, offset, length); + return Bits.readLong(decrypted_checksum, 0); + } + + + /* Get the algorithm name from "algorithm/mode/padding" taken from original ENCRYPT */ + protected static String getAlgorithm(String s) { + int index=s.indexOf('/'); + return index == -1? s : s.substring(0, index); + } + + + /** Called when the version shipped in the header can't be found */ + protected void handleUnknownVersion() {} + + + +} diff --git a/src/org/jgroups/protocols/EncryptHeader.java b/src/org/jgroups/protocols/EncryptHeader.java new file mode 100644 index 00000000000..201cdd8fc19 --- /dev/null +++ b/src/org/jgroups/protocols/EncryptHeader.java @@ -0,0 +1,80 @@ +package org.jgroups.protocols; + +import org.jgroups.Global; +import org.jgroups.Header; +import org.jgroups.util.Streamable; +import org.jgroups.util.Util; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @author Bela Ban + * @since 3.6.10 + */ +public class EncryptHeader extends Header implements Streamable { + public static final byte ENCRYPT = 1 << 0; + public static final byte SECRET_KEY_REQ = 1 << 1; + public static final byte SECRET_KEY_RSP = 1 << 2; + + protected byte type; + protected byte[] version; + protected byte[] signature; // the encrypted checksum + + + public EncryptHeader() {} + + + public EncryptHeader(byte type, byte[] version) { + this.type=type; + this.version=version; + } + + public byte getType() {return type;} + public byte[] getVersion() {return version;} + public byte[] getSignature() {return signature;} + public void setSignature(byte[] s) {this.signature=s;} + + public void writeExternal(java.io.ObjectOutput out) throws IOException + { + out.writeByte(type); + out.writeObject(version); + out.writeObject(signature); + } + + + public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException + { + type = in.readByte(); + version = (byte [])in.readObject(); + signature = (byte [])in.readObject(); + } + + public void writeTo(DataOutputStream out) throws IOException { + out.writeByte(type); + Util.writeByteBuffer(version, out); + Util.writeByteBuffer(signature, out); + } + + public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException { + type=in.readByte(); + version=Util.readByteBuffer(in); + signature=Util.readByteBuffer(in); + } + + public String toString() { + return String.format("[%s version=%s]", typeToString(type), (version != null? version.length + " bytes" : "n/a")); + } + + public int size() {return Global.BYTE_SIZE + Util.size(version) + Util.size(signature) /*+ Util.size(payload) */;} + + protected static String typeToString(byte type) { + switch(type) { + case ENCRYPT: return "ENCRYPT"; + case SECRET_KEY_REQ: return "SECRET_KEY_REQ"; + case SECRET_KEY_RSP: return "SECRET_KEY_RSP"; + default: return "<unrecognized type " + type; + } + } +} diff --git a/src/org/jgroups/protocols/SYM_ENCRYPT.java b/src/org/jgroups/protocols/SYM_ENCRYPT.java new file mode 100644 index 00000000000..115e571c3c3 --- /dev/null +++ b/src/org/jgroups/protocols/SYM_ENCRYPT.java @@ -0,0 +1,187 @@ +package org.jgroups.protocols; + +import org.jgroups.util.Util; + +import javax.crypto.SecretKey; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.Properties; + +/** + * Encrypts and decrypts communication in JGroups by using a secret key shared by all cluster members.<p> + * + * The secret key is identical for all cluster members and is injected into this protocol at startup, e.g. by reading + * it from a keystore. Messages are sent by encrypting them with the secret key and received by decrypting them with + * the secret key. Note that all cluster members must be shipped with the same keystore file<p> + * + * This protocol is typically placed under {@link org.jgroups.protocols.pbcast.NAKACK}, so that most important + * headers are encrypted as well, to prevent replay attacks.<p> + * + * A possible configuration looks like this:<br><br> + * {@code <SYM_ENCRYPT key_store_name="defaultStore.keystore" store_password="changeit" alias="myKey"/>} + * <br> + * <br> + * In order to use SYM_ENCRYPT layer in this manner, it is necessary to have the secret key already generated in a + * keystore file. The directory containing the keystore file must be on the application's classpath. You cannot create a + * secret key keystore file using the keytool application shipped with the JDK. A java file called KeyStoreGenerator is + * included in the demo package that can be used from the command line (or IDE) to generate a suitable keystore. + * + * @author Bela Ban + * @author Steve Woodcock + */ +public class SYM_ENCRYPT extends EncryptBase { + + /* ----------------------------------------- Properties -------------------------------------------------- */ + // File on classpath that contains keystore repository + protected String keystore_name; + + // Password used to check the integrity/unlock the keystore. Change the default + protected String store_password="changeit"; // JDK default + + // Password for recovering the key. Change the default" + protected String key_password; // allows to assign keypwd=storepwd if not set (https://issues.jboss.org/browse/JGRP-1375) + + + // Alias used for recovering the key. Change the default" + protected String alias="mykey"; // JDK default + + + public String getKeystoreName() {return this.keystore_name;} + public void setKeystoreName(String n) {this.keystore_name=n;} + public String getAlias() {return alias;} + public void setAlias(String a) {this.alias=a;} + public String getStorePassword() {return store_password;} + public void setStorePassword(String pwd) {this.store_password=pwd;} + + + public String getName() + { + return "SYM_ENCRYPT"; + } + + public boolean setProperties(Properties props) + { + String str; + + super.setProperties(props); + + // key store name + str = props.getProperty("keystore_name"); + if (str != null) + { + keystore_name = str; + props.remove("keystore_name"); + + if (log.isInfoEnabled()) + log.info("keystore_name used is " + keystore_name); + } + + // key store password + str = props.getProperty("store_password"); + if (str != null) + { + store_password = str; + props.remove("store_password"); + + if (log.isInfoEnabled()) + log.info("store_password used is not null"); + } + + // key password + str = props.getProperty("key_password"); + if (str != null) + { + key_password = str; + props.remove("key_password"); + + if (log.isInfoEnabled()) + log.info("key_password used is not null"); + } else if (store_password != null) + { + key_password = store_password; + + if (log.isInfoEnabled()) + log.info("key_password used is same as store_password"); + } + + // key aliase + str = props.getProperty("alias"); + if (str != null) + { + alias = str; + props.remove("alias"); + + if (log.isInfoEnabled()) + log.info("alias used is " + alias); + } + + if (!props.isEmpty()) + { + + if (log.isErrorEnabled()) + log.error("these properties are not recognized:" + props); + return false; + } + + return true; + } + + + public void init() throws Exception { + readSecretKeyFromKeystore(); + super.init(); + } + + /** + * Initialisation if a supplied key is defined in the properties. This supplied key must be in a keystore which + * can be generated using the keystoreGenerator file in demos. The keystore must be on the classpath to find it. + */ + protected void readSecretKeyFromKeystore() throws Exception { + InputStream inputStream=null; + // must not use default keystore type - as it does not support secret keys + KeyStore store=KeyStore.getInstance("JCEKS"); + + SecretKey tempKey=null; + try { + if(this.secret_key == null) { // in case the secret key was set before, e.g. via injection in a unit test + // load in keystore using this thread's classloader + inputStream=Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore_name); + if(inputStream == null) + inputStream=new FileInputStream(keystore_name); + // we can't find a keystore here - + if(inputStream == null) + throw new Exception("Unable to load keystore " + keystore_name + " ensure file is on classpath"); + // we have located a file lets load the keystore + try { + store.load(inputStream, store_password.toCharArray()); + // loaded keystore - get the key + tempKey=(SecretKey)store.getKey(alias, key_password.toCharArray()); + } + catch(IOException e) { + throw new Exception("Unable to load keystore " + keystore_name + ": " + e); + } + catch(NoSuchAlgorithmException e) { + throw new Exception("No Such algorithm " + keystore_name + ": " + e); + } + catch(CertificateException e) { + throw new Exception("Certificate exception " + keystore_name + ": " + e); + } + + if(tempKey == null) + throw new Exception("Unable to retrieve key '" + alias + "' from keystore " + keystore_name); + this.secret_key=tempKey; + if(sym_algorithm.equals(DEFAULT_SYM_ALGO)) + sym_algorithm=tempKey.getAlgorithm(); + } + } + finally { + Util.close(inputStream); + } + } + + +} diff --git a/src/org/jgroups/protocols/UNICAST.java b/src/org/jgroups/protocols/UNICAST.java index f278d738b8a..32a9001e6c8 100644 --- a/src/org/jgroups/protocols/UNICAST.java +++ b/src/org/jgroups/protocols/UNICAST.java @@ -295,7 +295,7 @@ public Object up(Event evt) { msg=(Message)evt.getArg(); dst=msg.getDest(); - if(dst == null || dst.isMulticastAddress()) // only handle unicast messages + if(dst == null || dst.isMulticastAddress() || msg.isFlagSet(Message.NO_RELIABILITY)) // only handle unicast messages break; // pass up // changed from removeHeader(): we cannot remove the header because if we do loopback=true at the @@ -338,7 +338,7 @@ public Object down(Event evt) { Address dst=msg.getDest(); /* only handle unicast messages */ - if (dst == null || dst.isMulticastAddress()) { + if (dst == null || dst.isMulticastAddress() || msg.isFlagSet(Message.NO_RELIABILITY)) { break; } diff --git a/src/org/jgroups/protocols/pbcast/ClientGmsImpl.java b/src/org/jgroups/protocols/pbcast/ClientGmsImpl.java index 0bc254e28f3..c716cbb3fad 100644 --- a/src/org/jgroups/protocols/pbcast/ClientGmsImpl.java +++ b/src/org/jgroups/protocols/pbcast/ClientGmsImpl.java @@ -67,6 +67,7 @@ private void join(Address mbr, boolean joinWithStateTransfer) { Address coord=null; JoinRsp rsp=null; View tmp_view; + long join_attempts=0; leaving=false; join_promise.reset(); @@ -134,8 +135,15 @@ private void join(Address mbr, boolean joinWithStateTransfer) { if(rsp == null) rsp=join_promise.getResult(gms.join_timeout); if(rsp == null) { + join_attempts++; if(log.isWarnEnabled()) log.warn("join(" + mbr + ") sent to " + coord + " timed out (after " + gms.join_timeout + " ms), retrying"); + if(gms.max_join_attempts != 0 && join_attempts >= gms.max_join_attempts) { + if(log.isWarnEnabled()) + log.warn("Too many JOIN attempts: becoming singleton"); + becomeSingletonMember(mbr); + return; + } } else { // 1. check whether JOIN was rejected diff --git a/src/org/jgroups/protocols/pbcast/GMS.java b/src/org/jgroups/protocols/pbcast/GMS.java index 6209b5d1929..542e8466344 100644 --- a/src/org/jgroups/protocols/pbcast/GMS.java +++ b/src/org/jgroups/protocols/pbcast/GMS.java @@ -41,6 +41,8 @@ long join_timeout=5000; long leave_timeout=5000; long merge_timeout=5000; // time to wait for all MERGE_RSPS + /** Number of join attempts before we give up and become a singleton. Zero means 'never give up */ + long max_join_attempts=0; private final Object impl_mutex=new Object(); // synchronizes event entry into impl private final Hashtable<String,GmsImpl> impls=new Hashtable<String,GmsImpl>(3); private boolean shun=false; @@ -122,6 +124,8 @@ public String getName() { public long getJoinRetryTimeout() {return -1;} /** @deprecated */ public void setJoinRetryTimeout(long t) {} + public long getMaxJoinAttempts() {return max_join_attempts;} + public void setMaxJoinAttempts(long t) {max_join_attempts=t;} public boolean isShun() {return shun;} public void setShun(boolean s) {shun=s;} @@ -969,6 +973,12 @@ public boolean setProperties(Properties props) { props.remove("resume_task_timeout"); } + str=props.getProperty("max_join_attempts"); + if(str != null) { + max_join_attempts=Long.parseLong(str); + props.remove("max_join_attempts"); + } + str=props.getProperty("disable_initial_coord"); if(str != null) { disable_initial_coord=Boolean.valueOf(str).booleanValue(); @@ -1122,6 +1132,10 @@ public Address getMember() { return mbr; } + public void setMergeRejected(boolean merge_rejected) { + this.merge_rejected=merge_rejected; + } + public String toString() { StringBuilder sb=new StringBuilder("GmsHeader"); sb.append('[' + type2String(type) + ']'); diff --git a/src/org/jgroups/protocols/pbcast/NAKACK.java b/src/org/jgroups/protocols/pbcast/NAKACK.java index 5d42b874288..0f2a819a9e2 100644 --- a/src/org/jgroups/protocols/pbcast/NAKACK.java +++ b/src/org/jgroups/protocols/pbcast/NAKACK.java @@ -102,7 +102,7 @@ private boolean leaving=false; private boolean started=false; private TimeScheduler timer=null; - private static final String name="NAKACK"; + public static final String name="NAKACK"; private long xmit_reqs_received; private long xmit_reqs_sent; @@ -598,7 +598,7 @@ public Object down(Event evt) { case Event.MSG: Message msg=(Message)evt.getArg(); Address dest=msg.getDest(); - if(dest != null && !dest.isMulticastAddress()) { + if((dest != null && !dest.isMulticastAddress()) || msg.isFlagSet(Message.NO_RELIABILITY)) { break; // unicast address: not null and not mcast, pass down unchanged } send(evt, msg); @@ -687,6 +687,8 @@ public Object up(Event evt) { case Event.MSG: Message msg=(Message)evt.getArg(); + if(msg.isFlagSet(Message.NO_RELIABILITY)) + break; NakAckHeader hdr=(NakAckHeader)msg.getHeader(name); if(hdr == null) break; // pass up (e.g. unicast msg) diff --git a/src/org/jgroups/util/AsciiString.java b/src/org/jgroups/util/AsciiString.java new file mode 100644 index 00000000000..4b985633478 --- /dev/null +++ b/src/org/jgroups/util/AsciiString.java @@ -0,0 +1,84 @@ +package org.jgroups.util; + +/** + * Simple string implemented as a byte[] array. Each character's higher 8 bits are truncated and + * only the lower 8 bits are stored. AsciiString is mutable for efficiency reasons, but the chars array should never + * be changed ! + * @author Bela Ban + * @since 3.5 + */ +public class AsciiString implements Comparable<AsciiString> { + protected final byte[] val; + + public AsciiString() { + val=new byte[]{}; + } + + public AsciiString(String str) { + int length=str != null? str.length() : 0; + this.val=new byte[length]; + for(int i=0; i < length; i++) + val[i]=(byte)str.charAt(i); + } + + public AsciiString(AsciiString str) { + this.val=str.val; + } + + public AsciiString(byte[] val) { + this.val=val; // mutable, used only for creation + } + + public AsciiString(int length) { + this.val=new byte[length]; + } + + public byte[] chars() {return val;} // mutable + + public int length() { + return val.length; + } + + public int compareTo(AsciiString str) { + if(str == null) return 1; + if(chars().hashCode() == str.val.hashCode()) + return 0; + + int len1=val.length; + int len2=str.val.length; + int lim=Math.min(len1, len2); + byte[] v1=val; + byte[] v2=str.val; + + int k = 0; + while (k < lim) { + byte c1 =v1[k]; + byte c2 =v2[k]; + if (c1 != c2) + return c1 > c2? 1 : -1; + k++; + } + return len1 > len2? 1 : len1 < len2? -1 : 0; + } + + + + public boolean equals(Object obj) { + return obj instanceof AsciiString && compareTo((AsciiString)obj) == 0; + } + + public int hashCode() { + int h=0; + for(int i=0; i < val.length; i++) + h=31 * h + val[i]; + return h; + } + + public String toString() { + return new String(val); + } + + + + +} diff --git a/src/org/jgroups/util/Bits.java b/src/org/jgroups/util/Bits.java new file mode 100644 index 00000000000..39e34c8aa0c --- /dev/null +++ b/src/org/jgroups/util/Bits.java @@ -0,0 +1,773 @@ +package org.jgroups.util; + +import org.jgroups.Global; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * Class (similar to (and partly copied from) java.nio.Bits) containing helper methods to encode variables + * (e.g. ints, long, List&lt;Address&gt; etc) to memory (byte buffer) or output streams and read variables + * from memory or input streams.<p/> + * The write methods write a type (e.g. an int or a char) to a buffer ({@link ByteBuffer} or output stream, using + * <a href="https://developers.google.com/protocol-buffers/docs/encoding">variable-length encoding</a>. If + * there are not enough byte in the buffer to write a type, a {@link java.nio.BufferOverflowException} is thrown. + * If the variable cannot be written to the output stream, an IOException is thrown. + * <p/> + * The read methods read a variable-length encoded type from a buffer or input stream. If there are fewer bytes in + * the buffer than needed to read the type, a {@link java.nio.BufferUnderflowException} is thrown. If the read fails, + * an IOException is thrown. + * <p/> + * The size() methods return the number of bytes used to encode the given type with variable-length encoding. + * <p/> + * There are additional helper methods to write/read custom JGroups types, e.g. address lists, Views etc + * <p/> + * Note that methods to read/write atomic types (char, int etc) should only be used if variable-length encoding is + * desired; otherwise {@link DataOutput#writeInt(int)} or {@link ByteBuffer#putInt(int)} should be used instead. + * <p/> + * At the time of writing this (Feb 2014), most methods have not yet been implemented. + * @author Bela Ban + * @author Sanne Grinovero + * @since 3.5 + */ +public final class Bits { + + private Bits() { + throw new InstantiationError( "Must not instantiate this class" ); + } + + // -------------------- char ------------------------ // + + // No compression of chars as they only use 2 bytes + public static char makeChar(byte[] buf, int offset) { + return (char) ((buf[offset + 1] & 0xFF) + (buf[offset] << 8)); + } + + public static void writeChar(char c, byte[] buf, int offset) { + buf[offset+1]=(byte)c; + buf[offset]=(byte)(c >>> 8); + } + + public static char readChar(byte[] buf, int offset) { + return makeChar(buf, offset); + } + + // -------------------- short ----------------------- // + + // No implementations as encoding a char doesn't use much space + + public static short makeShort(byte a, byte b) { + return (short)((a << 8) | (b & 0xff)); + } + + public static short makeShort(byte a) { + return (short) (a & 0xff); + } + + public static void writeShort(short s, byte[] buf, int offset) { + buf[offset+1]=(byte)s; + buf[offset]=(byte)(s >>> 8); + } + + public static short readShort(byte[] buf, int offset) { + return (short)((buf[offset+1] & 0xFF) + (buf[offset] << 8)); + } + + // --------------------- int ------------------------ // + + + /** + * Writes an int to a ByteBuffer + * @param num the int to be written + * @param buf the buffer + */ + public static void writeInt(int num, ByteBuffer buf) { + if(num == 0) { + buf.put((byte)0); + return; + } + final byte bytes_needed=bytesRequiredFor(num); + buf.put(bytes_needed); + for(int i=0; i < bytes_needed; i++) + buf.put(getByteAt(num, i)); + } + + /** + * Writes an int to an output stream + * @param num the int to be written + * @param out the output stream + */ + public static void writeInt(int num, DataOutput out) throws IOException { + if(num == 0) { + out.write(0); + return; + } + final byte bytes_needed=bytesRequiredFor(num); + out.write(bytes_needed); + for(int i=0; i < bytes_needed; i++) + out.write(getByteAt(num, i)); + } + + public static void writeInt(int num, byte[] buf, int offset) { + buf[offset+3]=(byte)num; + buf[offset+2]=(byte)(num >>> 8); + buf[offset+1]=(byte)(num >>> 16); + buf[offset]=(byte)(num >>> 24); + } + + public static void writeIntCompressed(int num, byte[] buf, int offset) { + if(num == 0) { + buf[offset]=0; + return; + } + final byte bytes_needed=bytesRequiredFor(num); + buf[offset++]=bytes_needed; + for(int i=0; i < bytes_needed; i++) + buf[offset++]=getByteAt(num, i); + } + + + /** + * Reads an int from a buffer. + * @param buf the buffer + * @return the int read from the buffer + */ + public static int readInt(ByteBuffer buf) { + byte len=buf.get(); + if(len == 0) + return 0; + byte[] retval=new byte[len]; + buf.get(retval, 0, len); + return makeInt(retval, 0, len); + } + + /** + * Reads an int from an input stream + * @param in the input stream + * @return the int read from the input stream + */ + public static int readInt(DataInput in) throws IOException { + byte len=in.readByte(); + if(len == 0) + return 0; + byte[] buf=new byte[len]; + in.readFully(buf, 0, len); + return makeInt(buf, 0, len); + } + + public static int readInt(byte[] buf, int offset) { + return ((buf[offset+3] & 0xFF)) + + ((buf[offset+2] & 0xFF) << 8) + + ((buf[offset+1] & 0xFF) << 16) + + ((buf[offset]) << 24); + } + + public static int readIntCompressed(byte[] buf, int offset) { + byte len=buf[offset++]; + if(len == 0) + return 0; + byte[] buffer=new byte[len]; + for(int i=0; i < len; i++) + buffer[i]=buf[offset++]; + return makeInt(buffer, 0, len); + } + + + /** + * Computes the size of a variable-length encoded int + * @param num the int + * @return the number of bytes needed to variable-length encode num + */ + public static int size(int num) { + return (byte)(num == 0? 1 : bytesRequiredFor(num) +1); + } + + + + + // -------------------- long ------------------------ // + + /** + * Writes a long to a ByteBuffer + * @param num the long to be written + * @param buf the buffer + */ + public static void writeLong(long num, ByteBuffer buf) { + if(num == 0) { + buf.put((byte)0); + return; + } + final byte bytes_needed=bytesRequiredFor(num); + buf.put(bytes_needed); + for(int i=0; i < bytes_needed; i++) + buf.put(getByteAt(num, i)); + } + + /** + * Writes a long to out in variable-length encoding. Note that currently variable-length encoding is <em>not</em> + * used (a similar mechanism is used); this will be implemented later. + * @param num the long + * @param out the output stream to write num to + * @throws IOException + */ + public static void writeLong(final long num, final DataOutput out) throws IOException { + if(num == 0) { + out.write(0); + return; + } + final byte bytes_needed=bytesRequiredFor(num); + out.write(bytes_needed); + for(int i=0; i < bytes_needed; i++) + out.write(getByteAt(num, i)); + } + + public static void writeLong(long num, byte[] buf, int offset) { + buf[offset+7]=(byte)num; + buf[offset+6]=(byte)(num >>> 8); + buf[offset+5]=(byte)(num >>> 16); + buf[offset+4]=(byte)(num >>> 24); + buf[offset+3]=(byte)(num >>> 32); + buf[offset+2]=(byte)(num >>> 40); + buf[offset+1]=(byte)(num >>> 48); + buf[offset]=(byte)(num >>> 56); + } + + public static void writeLongCompressed(long num, byte[] buf, int offset) { + if(num == 0) { + buf[offset]=0; + return; + } + final byte bytes_needed=bytesRequiredFor(num); + buf[offset++]=bytes_needed; + for(int i=0; i < bytes_needed; i++) + buf[offset++]=getByteAt(num, i); + } + + + + /** + * Reads a long from a buffer. + * @param buf the buffer + * @return the long read from the buffer + */ + public static long readLong(ByteBuffer buf) { + byte len=buf.get(); + if(len == 0) + return 0; + byte[] retval=new byte[len]; + buf.get(retval, 0, len); + return makeLong(retval, 0, len); + } + + /** + * Reads a variable-length encoded long from an input stream. Note that currently variable-length encoding is <em>not</em> + * used (a similar mechanism is used); this will be implemented later. + * @param in the input stream + * @return the long read from the input stream + * @throws IOException + */ + public static long readLong(DataInput in) throws IOException { + byte len=in.readByte(); + if(len == 0) + return 0; + byte[] buf=new byte[len]; + in.readFully(buf, 0, len); + return makeLong(buf, 0, len); + } + + public static long readLong(byte[] buf, int offset) { + return ((buf[offset+7] & 0xFFL)) + + ((buf[offset+6] & 0xFFL) << 8) + + ((buf[offset+5] & 0xFFL) << 16) + + ((buf[offset+4] & 0xFFL) << 24) + + ((buf[offset+3] & 0xFFL) << 32) + + ((buf[offset+2] & 0xFFL) << 40) + + ((buf[offset+1] & 0xFFL) << 48) + + (((long) buf[offset]) << 56); + } + + public static long readLongCompressed(byte[] buf, int offset) { + byte len=buf[offset++]; + if(len == 0) + return 0; + byte[] buffer=new byte[len]; + for(int i=0; i < len; i++) + buffer[i]=buf[offset++]; + return makeLong(buffer, 0, len); + } + + /** + * Computes the size of a variable-length encoded long. Note that this is <em>not</em> currently using + * variable-length encoding (will be implemented later). + * @param num the long + * @return the number of bytes needed to variable-length encode num + */ + public static int size(long num) { + return (byte)(num == 0? 1 : bytesRequiredFor(num) +1); + } + + + + + + // ------------------ long seq ---------------------- // + + /** + * Writes 2 sequence numbers (seqnos) in compressed format to buf. + * The seqnos are non-negative and hr is guaranteed to be &gt;= hd. + * <p/> + * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply + * write the 2 longs individually. + * @param hd the highest delivered seqno. Guaranteed to be a positive number + * @param hr the highest received seqno. Guaranteed to be a positive number. Greater than or equal to hd + * @param buf the buffer to write to + */ + public static void writeLongSequence(long hd, long hr, ByteBuffer buf) { + if(hr < hd) + throw new IllegalArgumentException("hr (" + hr + ") has to be >= hd (" + hd + ")"); + + if(hd == 0 && hr == 0) { + buf.put((byte)0); + return; + } + + long delta=hr - hd; + + // encode highest_delivered followed by delta + byte bytes_for_hd=bytesRequiredFor(hd), bytes_for_delta=bytesRequiredFor(delta); + byte bytes_needed=encodeLength(bytes_for_hd, bytes_for_delta); + buf.put(bytes_needed); + + for(int i=0; i < bytes_for_hd; i++) + buf.put(getByteAt(hd, i)); + + for(int i=0; i < bytes_for_delta; i++) + buf.put(getByteAt(delta, i)); + } + + /** + * Writes 2 sequence numbers (seqnos) in compressed format to an output stream. + * The seqnos are non-negative and hr is guaranteed to be &gt;= hd. + * <p/> + * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply + * write the 2 longs individually. + * @param hd the highest delivered seqno. Guaranteed to be a positive number + * @param hr the highest received seqno. Guaranteed to be a positive number. Greater than or equal to hd + * @param out the output stream to write to + */ + public static void writeLongSequence(long hd, long hr, DataOutput out) throws IOException { + if(hr < hd) + throw new IllegalArgumentException("hr (" + hr + ") has to be >= hd (" + hd + ")"); + + if(hd == 0 && hr == 0) { + out.write(0); + return; + } + + long delta=hr - hd; + + // encode highest_delivered followed by delta + byte bytes_for_hd=bytesRequiredFor(hd), bytes_for_delta=bytesRequiredFor(delta); + byte bytes_needed=encodeLength(bytes_for_hd, bytes_for_delta); + out.write(bytes_needed); + + for(int i=0; i < bytes_for_hd; i++) + out.write(getByteAt(hd, i)); + + for(int i=0; i < bytes_for_delta; i++) + out.write(getByteAt(delta, i)); + } + + /** + * Reads 2 compressed longs from buf. + * <p/> + * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply + * read the 2 longs individually. + * @param buf the buffer to read from + * @return an array of 2 longs (hd and hr) + */ + public static long[] readLongSequence(ByteBuffer buf) { + byte len=buf.get(); + if(len == 0) + return new long[]{0,0}; + + byte[] lengths=decodeLength(len); + long[] seqnos=new long[2]; + byte[] retval=new byte[lengths[0] + lengths[1]]; + buf.get(retval, 0, retval.length); + seqnos[0]=makeLong(retval, 0, lengths[0]); + seqnos[1]=makeLong(retval, lengths[0], lengths[1]) + seqnos[0]; + return seqnos; + } + + /** + * Reads 2 compressed longs from in. + * Reads 2 compressed longs from buf. + * <p/> + * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply + * read the 2 longs individually. + * @param in the input stream to read from + * @return an array of 2 longs (hd and hr) + */ + public static long[] readLongSequence(DataInput in) throws IOException { + byte len=in.readByte(); + if(len == 0) + return new long[]{0,0}; + + byte[] lengths=decodeLength(len); + long[] seqnos=new long[2]; + byte[] buf=new byte[lengths[0] + lengths[1]]; + in.readFully(buf, 0, buf.length); + seqnos[0]=makeLong(buf, 0, lengths[0]); + seqnos[1]=makeLong(buf, lengths[0], lengths[1]) + seqnos[0]; + return seqnos; + } + + + + public static byte size(long hd, long hr) { + if(hd == 0 && hr == 0) + return 1; + + byte num_bytes_for_hd=bytesRequiredFor(hd), num_bytes_for_delta=bytesRequiredFor(hr - hd); + return (byte)(num_bytes_for_hd + num_bytes_for_delta + 1); + } + + public static long makeLong(byte[] buf, int offset, int bytes_to_read) { + long retval=0; + for(int i=0; i < bytes_to_read; i++) { + byte b=buf[offset + i]; + retval |= ((long)b & 0xff) << (i * 8); + } + return retval; + } + + public static int makeInt(byte[] buf, int offset, int bytes_to_read) { + int retval=0; + for(int i=0; i < bytes_to_read; i++) { + byte b=buf[offset + i]; + retval |= ((int)b & 0xff) << (i * 8); + } + return retval; + } + + + + // -------------------- float ----------------------- // + + /** + * Writes a float to a ByteBuffer + * @param num the float to be written + * @param buf the buffer + */ + public static void writeFloat(float num, ByteBuffer buf) { + writeInt(Float.floatToIntBits(num), buf); + } + + /** + * Writes a float to an output stream + * @param num the float to be written + * @param out the output stream + */ + public static void writeFloat(float num, DataOutput out) throws IOException { + writeInt(Float.floatToIntBits(num), out); + } + + public static void writeFloat(float num, byte[] buf, int offset) { + writeInt(Float.floatToIntBits(num), buf, offset); + } + + /** + * Reads a a float from a buffer. + * @param buf the buffer + * @return the float read from the buffer + */ + public static float readFloat(ByteBuffer buf) { + return Float.intBitsToFloat(readInt(buf)); + } + + /** + * Reads a a float from an input stream. + * @param in the input stream + * @return the float read from the input stream + */ + public static float readFloat(DataInput in) throws IOException { + return Float.intBitsToFloat(readInt(in)); + } + + public static float readFloat(byte[] buf, int offset) { + return Float.intBitsToFloat(readInt(buf, offset)); + } + + + /** + * Computes the size of a variable-length encoded float + * @param num the float + * @return the number of bytes needed to variable-length encode num + */ + public static int size(float num) { + return size(Float.floatToIntBits(num)); + } + + + + // -------------------- double ---------------------- // + + /** + * Writes a double to a ByteBuffer + * @param num the double to be written + * @param buf the buffer + */ + public static void writeDouble(double num, ByteBuffer buf) { + writeLong(Double.doubleToLongBits(num), buf); + } + + /** + * Writes a double to an output stream + * @param num the double to be written + * @param out the output stream + */ + public static void writeDouble(double num, DataOutput out) throws IOException { + writeLong(Double.doubleToLongBits(num), out); + } + + public static void writeDouble(double num, byte[] buf, int offset) { + writeLong(Double.doubleToLongBits(num), buf, offset); + } + + + /** + * Reads a double from a buffer. + * @param buf the buffer + * @return the double read from the buffer + */ + public static double readDouble(ByteBuffer buf) { + return Double.longBitsToDouble(readLong(buf)); + } + + /** + * Reads a double from an input stream + * @param in the input stream + * @return the double read from the input stream + */ + public static double readDouble(DataInput in) throws IOException { + return Double.longBitsToDouble(readLong(in)); + } + + public static double readDouble(byte[] buf, int offset) { + return Double.longBitsToDouble(readLong(buf, offset)); + } + + /** + * Computes the size of a variable-length encoded double + * @param num the double + * @return the number of bytes needed to variable-length encode num + */ + public static int size(double num) { + return size(Double.doubleToLongBits(num)); + } + + + + + // -------------------- String ---------------------- // + + /** + * Writes a string to buf. The length of the string is written first, followed by the chars (as single-byte values). + * Multi-byte values are truncated: only the lower byte of each multi-byte char is written, similar to + * {@link DataOutput#writeChars(String)}. + * @param s the string + * @param buf the buffer + */ + public static void writeString(String s, ByteBuffer buf) { + buf.put((byte)(s != null? 1 : 0)); + if(s != null) { + byte[] bytes=s.getBytes(); + writeInt(bytes.length, buf); + buf.put(bytes); + } + } + + /** + * Writes a string to buf. The length of the string is written first, followed by the chars (as single-byte values). + * Multi-byte values are truncated: only the lower byte of each multi-byte char is written, similar to + * {@link DataOutput#writeChars(String)}. + * @param s the string + * @param out the output stream + */ + public static void writeString(String s, DataOutput out) throws IOException { + if(s != null) { + out.write(1); + out.writeUTF(s); + } + else + out.write(0); + } + + /** + * Reads a string from buf. The length is read first, followed by the chars. Each char is a single byte + * @param buf the buffer + * @return the string read from buf + */ + public static String readString(ByteBuffer buf) { + if(buf.get() == 0) + return null; + int len=readInt(buf); + byte[] bytes=new byte[len]; + buf.get(bytes); + return new String(bytes); + } + + /** + * Reads a string from buf. The length is read first, followed by the chars. Each char is a single byte + * @param in the input stream + * @return the string read from buf + */ + public static String readString(DataInput in) throws IOException { + int b=in.readByte(); + if(b == 1) + return in.readUTF(); + return null; + } + + + /** + * Measures the number of bytes required to encode a string, taking multibyte characters into account. Measures + * strings written by {@link DataOutput#writeUTF(String)}. + * @param str the string + * @return the number of bytes required for encoding str + */ + public static int sizeUTF(String str) { + int len=str != null? str.length() : 0, utflen=2; + if(len == 0) + return utflen; + for(int i = 0; i < len; i++) { + int c=str.charAt(i); + if((c >= 0x0001) && (c <= 0x007F)) + utflen++; + else if (c > 0x07FF) + utflen += 3; + else + utflen += 2; + } + return utflen; + } + + public static int size(String str) { + if(str == null) + return Global.BYTE_SIZE; + byte[] bytes=str.getBytes(); + return Global.BYTE_SIZE + size(bytes.length) + bytes.length; + } + + + + // ------------------ AsciiString ------------------- // + /** + * Writes an AsciiString to buf. The length of the string is written first, followed by the chars (as single-byte values). + * @param s the string + * @param buf the buffer + */ + public static void writeAsciiString(AsciiString s, ByteBuffer buf) { + short length=(short)(s != null? s.length() : -1); + buf.putShort(length); + if(s != null) + buf.put(s.chars()); + } + + /** + * Writes an AsciiString to buf. The length of the string is written first, followed by the chars (as single-byte values). + * @param s the string + * @param out the output stream + */ + public static void writeAsciiString(AsciiString s, DataOutput out) throws IOException { + short length=(short)(s != null? s.length() : -1); + out.writeShort(length); + if(s != null) + out.write(s.chars()); + } + + /** + * Reads an AsciiString from buf. The length is read first, followed by the chars. Each char is a single byte + * @param buf the buffer + * @return the string read from buf + */ + public static AsciiString readAsciiString(ByteBuffer buf) { + short len=buf.getShort(); + if(len < 0) + return null; + AsciiString retval=new AsciiString(len); + buf.get(retval.chars()); + return retval; + } + + /** + * Reads an AsciiString from buf. The length is read first, followed by the chars. Each char is a single byte + * @param in the input stream + * @return the string read from buf + */ + public static AsciiString readAsciiString(DataInput in) throws IOException { + short len=in.readShort(); + if(len < 0) + return null; + AsciiString retval=new AsciiString(len); + in.readFully(retval.chars()); + return retval; + } + + + /** + * Measures the number of bytes required to encode an AsciiSring. + * @param str the string + * @return the number of bytes required for encoding str + */ + public static int size(AsciiString str) { + return str == null? Global.SHORT_SIZE : Global.SHORT_SIZE + str.length(); + } + + + + /** + * Encodes the number of bytes needed into a single byte. The first number is encoded in the first nibble (the + * first 4 bits), the second number in the second nibble + * @param len1 The number of bytes needed to store a long. Must be between 0 and 8 + * @param len2 The number of bytes needed to store a long. Must be between 0 and 8 + * @return The byte storing the 2 numbers len1 and len2 + */ + protected static byte encodeLength(byte len1, byte len2) { + byte retval=len2; + retval |= (len1 << 4); + return retval; + } + + protected static byte[] decodeLength(byte len) { + return new byte[]{(byte)((len & 0xff) >> 4),(byte)(len & ~0xf0)}; // 0xf0 is the first nibble set (11110000) + } + + protected static byte bytesRequiredFor(long number) { + if(number >> 56 != 0) return 8; + if(number >> 48 != 0) return 7; + if(number >> 40 != 0) return 6; + if(number >> 32 != 0) return 5; + if(number >> 24 != 0) return 4; + if(number >> 16 != 0) return 3; + if(number >> 8 != 0) return 2; + return 1; + } + + protected static byte bytesRequiredFor(int number) { + if(number >> 24 != 0) return 4; + if(number >> 16 != 0) return 3; + if(number >> 8 != 0) return 2; + return 1; + } + + + static protected byte getByteAt(long num, int index) { + return (byte)((num >> (index * 8))); + } + + +} diff --git a/src/org/jgroups/util/MyReceiver.java b/src/org/jgroups/util/MyReceiver.java new file mode 100644 index 00000000000..27622a88e59 --- /dev/null +++ b/src/org/jgroups/util/MyReceiver.java @@ -0,0 +1,35 @@ +package org.jgroups.util; + +import org.jgroups.Message; +import org.jgroups.ReceiverAdapter; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * Generic receiver for a JChannel + * @author Bela Ban + * @since 3.3 + */ +public class MyReceiver<T> extends ReceiverAdapter { + protected final List<T> list=new CopyOnWriteArrayList<T>(); + protected String name; + protected boolean verbose; + protected boolean raw_msgs; + + public void receive(Message msg) { + T obj=raw_msgs? (T)msg : (T)msg.getObject(); + list.add(obj); + if(verbose) { + System.out.println((name() != null? name() + ":" : "") + " received message from " + msg.getSrc() + ": " + obj); + } + } + + public MyReceiver rawMsgs(boolean flag) {this.raw_msgs=flag; return this;} + public List<T> list() {return list;} + public MyReceiver<T> verbose(boolean flag) {verbose=flag; return this;} + public String name() {return name;} + public MyReceiver<T> name(String name) {this.name=name; return this;} + public MyReceiver<T> reset() {list.clear(); return this;} + public int size() {return list.size();} +} diff --git a/src/org/jgroups/util/Util.java b/src/org/jgroups/util/Util.java index 4ae2465779a..23d09bd8c19 100644 --- a/src/org/jgroups/util/Util.java +++ b/src/org/jgroups/util/Util.java @@ -446,7 +446,6 @@ public static Streamable streamableFromByteBuffer(Class cl, byte[] buffer, int o return result; } - public static byte[] collectionToByteBuffer(Collection c) throws Exception { byte[] result=null; final ByteArrayOutputStream out_stream=new ByteArrayOutputStream(512); @@ -2643,6 +2642,64 @@ public static String sha(String source) { } } + public static String byteArrayToHexString(byte[] b) { + if(b == null) + return "null"; + StringBuilder sb = new StringBuilder(b.length * 2); + for (int i = 0; i < b.length; i++){ + int v = b[i] & 0xff; + if (v < 16) { sb.append('0'); } + sb.append(Integer.toHexString(v)); + } + return sb.toString().toUpperCase(); + } + + public static int getNextHigherPowerOfTwo(int num) { + if(num <= 0) return 1; + int highestBit=Integer.highestOneBit(num); + return num <= highestBit? highestBit : highestBit << 1; + } + + public static int size(byte[] buf) { + return buf == null? Global.BYTE_SIZE : Global.BYTE_SIZE + Global.INT_SIZE + buf.length; + } + + /** + * Blocks until all channels have the same view + * @param timeout How long to wait (max in ms) + * @param interval Check every interval ms + * @param channels The channels which should form the view. The expected view size is channels.length. + * Must be non-null + */ + public static void waitUntilAllChannelsHaveSameSize(long timeout, long interval, Channel... channels) throws TimeoutException { + int size=channels.length; + + if(interval >= timeout || timeout <= 0) + throw new IllegalArgumentException("interval needs to be smaller than timeout or timeout needs to be > 0"); + long target_time=System.currentTimeMillis() + timeout; + while(System.currentTimeMillis() <= target_time) { + boolean all_channels_have_correct_size=true; + for(Channel ch: channels) { + View view=ch.getView(); + if(view == null || view.size() != size) { + all_channels_have_correct_size=false; + break; + } + } + if(all_channels_have_correct_size) + return; + Util.sleep(interval); + } + View[] views=new View[channels.length]; + StringBuilder sb=new StringBuilder(); + for(int i=0; i < channels.length; i++) { + views[i]=channels[i].getView(); + sb.append(channels[i].getLocalAddress()).append(": ").append(views[i]).append("\n"); + } + for(View view: views) + if(view == null || view.size() != size) + throw new TimeoutException("Timeout " + timeout + " kicked in, views are:\n" + sb); + } } diff --git a/tests/junit-functional/org/jgroups/tests/SizeTest.java b/tests/junit-functional/org/jgroups/tests/SizeTest.java index 7bb315c322f..e8f51b259a4 100644 --- a/tests/junit-functional/org/jgroups/tests/SizeTest.java +++ b/tests/junit-functional/org/jgroups/tests/SizeTest.java @@ -398,6 +398,10 @@ public void testEncryptHeader() throws Exception { _testSize(hdr); hdr=new ENCRYPT.EncryptHeader((short)2, "Hello world"); _testSize(hdr); + EncryptHeader hdr2=new EncryptHeader((byte)1, new byte[]{'b','e', 'l', 'a'}); + _testSize(hdr2); + hdr2=new EncryptHeader((byte)2, "Hello world".getBytes()); + _testSize(hdr2); } public void testIpAddress() throws Exception { diff --git a/tests/junit/org/jgroups/protocols/ASYM_ENCRYPT_Test.java b/tests/junit/org/jgroups/protocols/ASYM_ENCRYPT_Test.java new file mode 100644 index 00000000000..69670c378eb --- /dev/null +++ b/tests/junit/org/jgroups/protocols/ASYM_ENCRYPT_Test.java @@ -0,0 +1,297 @@ +package org.jgroups.protocols; + +import org.jgroups.*; +import org.jgroups.auth.MD5Token; +import org.jgroups.conf.ClassConfigurator; +import org.jgroups.protocols.pbcast.GMS; +import org.jgroups.protocols.pbcast.JoinRsp; +import org.jgroups.protocols.pbcast.NAKACK; +import org.jgroups.protocols.pbcast.STABLE; +import org.jgroups.stack.ProtocolStack; +import org.jgroups.util.Util; + +import javax.crypto.SecretKey; +import java.util.Arrays; +import java.util.Vector; +import java.util.Properties; + +/** + * Tests use cases for {@link ASYM_ENCRYPT} described in https://issues.jboss.org/browse/JGRP-2021. + * @author Bela Ban + * @since 4.0 + */ +public class ASYM_ENCRYPT_Test extends EncryptTest { + protected String getProtocolName() + { + return "ASYM_ENCRYPT"; + } + + /** + * A non-member sends a {@link EncryptHeader#SECRET_KEY_REQ} request to the key server. Asserts that the rogue member + * doesn't get the secret key. If it did, it would be able to decrypt all messages from cluster members! + */ + public void nonMemberGetsSecretKeyFromKeyServer() throws Exception { + Util.close(rogue); + + rogue=new JChannel(getTestStack()); + DISCARD discard=new DISCARD(); + discard.setDiscardAll(true); + rogue.getProtocolStack().insertProtocol(discard, ProtocolStack.ABOVE, TP.class); + CustomENCRYPT encrypt=new CustomENCRYPT(); + encrypt.setProperties(new Properties()); + encrypt.init(); + + rogue.getProtocolStack().insertProtocol(encrypt, ProtocolStack.BELOW, NAKACK.class); + rogue.connect(cluster_name); // creates a singleton cluster + + assert rogue.getView().size() == 1; + GMS gms=(GMS)rogue.getProtocolStack().findProtocol(GMS.class); + Vector<Address> members = new Vector<Address>(); + members.add(a.getLocalAddress()); + members.add(b.getLocalAddress()); + members.add(c.getLocalAddress()); + members.add(rogue.getLocalAddress()); + View rogue_view=new View(a.getLocalAddress(), a.getView().getVid().getId(), members); + gms.installView(rogue_view); + + + // now fabricate a KEY_REQUEST message and send it to the key server (A) + Message newMsg=new Message(a.getLocalAddress(), rogue.getLocalAddress(), encrypt.getKeyPair().getPublic().getEncoded()); + newMsg.putHeader(encrypt.getName(),new EncryptHeader(EncryptHeader.SECRET_KEY_REQ, encrypt.getSymVersion())); + + discard.setDiscardAll(false); + System.out.printf("-- sending KEY_REQUEST to key server %s\n", a.getLocalAddress()); + encrypt.getDownProtocol().down(new Event(Event.MSG, newMsg)); + for(int i=0; i < 10; i++) { + SecretKey secret_key=encrypt.key; + if(secret_key != null) + break; + Util.sleep(500); + } + + discard.setDiscardAll(true); + Vector<Address> rogueMember = new Vector<Address>(); + rogueMember.add(rogue.getLocalAddress()); + gms.installView(new View(rogue.getLocalAddress(), 20, rogueMember)); + System.out.printf("-- secret key is %s (should be null)\n", encrypt.key); + assert encrypt.key == null : String.format("should not have received secret key %s", encrypt.key); + } + + + + /** Verifies that a non-member (non-coord) cannot send a JOIN-RSP to a member */ + public void nonMemberInjectingJoinResponse() throws Exception { + Util.close(rogue); + rogue=create(); + ProtocolStack stack=rogue.getProtocolStack(); + AUTH auth=(AUTH)stack.findProtocol(AUTH.class); + auth.setAuthToken(new MD5Token("unknown_pwd")); + GMS gms=(GMS)stack.findProtocol(GMS.class); + gms.setMaxJoinAttempts(1); + DISCARD discard=new DISCARD(); + discard.setDiscardAll(true); + stack.insertProtocol(discard, ProtocolStack.ABOVE, TP.class); + rogue.connect(cluster_name); + assert rogue.getView().size() == 1; + discard.setDiscardAll(false); + stack.removeProtocol("NAKACK"); + stack.removeProtocol("UNICAST"); + + Vector<Address> members = new Vector<Address>(); + members.add(a.getLocalAddress()); + members.add(b.getLocalAddress()); + members.add(c.getLocalAddress()); + members.add(rogue.getLocalAddress()); + View rogue_view=new View(a.getLocalAddress(), a.getView().getVid().getId() +5, members); + JoinRsp join_rsp=new JoinRsp(rogue_view, null); + GMS.GmsHeader gms_hdr=new GMS.GmsHeader(GMS.GmsHeader.JOIN_RSP, join_rsp); + Message rogue_join_rsp=new Message(b.getLocalAddress(), rogue.getLocalAddress(), null); + rogue_join_rsp.putHeader(GMS.name, gms_hdr); + rogue_join_rsp.setFlag(Message.NO_RELIABILITY); // bypasses NAKACK / UNICAST + rogue.down(new Event(Event.MSG, rogue_join_rsp)); + for(int i=0; i < 10; i++) { + if(b.getView().size() > 3) + break; + Util.sleep(500); + } + assert b.getView().size() == 3 : String.format("B's view is %s, but should be {A,B,C}", b.getView()); + } + + + + /** The rogue node has an incorrect {@link AUTH} config (secret) and can thus not join */ + public void rogueMemberCannotJoinDueToAuthRejection() throws Exception { + Util.close(rogue); + rogue=create(); + AUTH auth=(AUTH)rogue.getProtocolStack().findProtocol(AUTH.class); + auth.setAuthToken(new MD5Token("unknown_pwd")); + GMS gms=(GMS)rogue.getProtocolStack().findProtocol(GMS.class); + gms.setMaxJoinAttempts(2); + rogue.connect(cluster_name); + System.out.printf("Rogue's view is %s\n", rogue.getView()); + assert rogue.getView().size() == 1 : String.format("rogue should have a singleton view of itself, but doesn't: %s", rogue.getView()); + } + + + public void mergeViewInjectionByNonMember() throws Exception { + Util.close(rogue); + rogue=create(); + AUTH auth=(AUTH)rogue.getProtocolStack().findProtocol(AUTH.class); + auth.setAuthToken(new MD5Token("unknown_pwd")); + GMS gms=(GMS)rogue.getProtocolStack().findProtocol(GMS.class); + gms.setMaxJoinAttempts(1); + rogue.connect(cluster_name); + + Vector<Address> members = new Vector<Address>(); + members.add(a.getLocalAddress()); + members.add(b.getLocalAddress()); + members.add(c.getLocalAddress()); + members.add(rogue.getLocalAddress()); + MergeView merge_view=new MergeView(a.getLocalAddress(), a.getView().getVid().getId()+5, members, null); + GMS.GmsHeader hdr=new GMS.GmsHeader(GMS.GmsHeader.INSTALL_MERGE_VIEW, merge_view); + Message merge_view_msg=new Message(null); + merge_view_msg.putHeader(GMS.name, hdr); + merge_view_msg.setFlag(Message.NO_RELIABILITY); + System.out.printf("** %s: trying to install MergeView %s in all members\n", rogue.getLocalAddress(), merge_view); + rogue.down(new Event(Event.MSG, merge_view_msg)); + + // check if A, B or C installed the MergeView sent by rogue: + for(int i=0; i < 10; i++) { + boolean rogue_views_installed=false; + + for(JChannel ch: Arrays.asList(a,b,c)) + if(ch.getView().containsMember(rogue.getLocalAddress())) + rogue_views_installed=true; + if(rogue_views_installed) + break; + Util.sleep(500); + } + for(JChannel ch: Arrays.asList(a,b,c)) + System.out.printf("%s: %s\n", ch.getLocalAddress(), ch.getView()); + for(JChannel ch: Arrays.asList(a,b,c)) + assert !ch.getView().containsMember(rogue.getLocalAddress()); + } + + + /** Tests that when {ABC} -> {AB}, neither A nor B can receive a message from non-member C */ + public void testMessagesByLeftMember() throws Exception { + Vector<Address> members = new Vector<Address>(); + members.add(a.getLocalAddress()); + members.add(b.getLocalAddress()); + View view=new View(a.getLocalAddress(), a.getView().getVid().getId()+1, members); + for(JChannel ch: Arrays.asList(a,b)) { + GMS gms=(GMS)ch.getProtocolStack().findProtocol(GMS.class); + gms.installView(view); + }; + printView(a,b,c); + c.getProtocolStack().removeProtocol("NAKACK"); // to prevent A and B from discarding C as non-member + + Util.sleep(1000); // give members time to handle the new view + c.send(new Message(null, null, "hello world from left member C!")); + for(int i=0; i < 10; i++) { + if(ra.size() > 0 || rb.size() > 0) + break; + Util.sleep(500); + } + assert ra.size() == 0 : String.format("A: received msgs from non-member C: %s", print(ra.list())); + assert rb.size() == 0 : String.format("B: received msgs from non-member C: %s", print(rb.list())); + } + + /** Tests that a left member C cannot decrypt messages from the cluster */ + public void testEavesdroppingByLeftMember() throws Exception { + printSymVersion(a,b,c); + Vector<Address> members = new Vector<Address>(); + members.add(a.getLocalAddress()); + members.add(b.getLocalAddress()); + View view=new View(a.getLocalAddress(), a.getView().getVid().getId()+1, members); + for(JChannel ch: Arrays.asList(a,b)) { + GMS gms=(GMS)ch.getProtocolStack().findProtocol(GMS.class); + gms.installView(view); + }; + printView(a,b,c); + c.getProtocolStack().removeProtocol("NAKACK"); // to prevent A and B from discarding C as non-member + Util.waitUntilAllChannelsHaveSameSize(10000, 500, a,b); + + // somewhat of a kludge as we don't have UNICAST: if we didn't remove C's connection to A, C might retransmit + // the JOIN-REQ to A and get added to the cluster, so the code below would fail as C would be able to eavesdrop + // on A and B + UNICAST uni=(UNICAST)c.getProtocolStack().findProtocol(UNICAST.class); + uni.removeConnection(a.getLocalAddress()); + Util.sleep(5000); // give members time to handle the new view + + printView(a,b,c); + printSymVersion(a,b,c); + a.send(new Message(null, null, "hello from A")); + b.send(new Message(null, null, "hello from B")); + + for(int i=0; i < 10; i++) { + if(rc.size() > 0) + break; + Util.sleep(500); + } + assert rc.size() == 0 : String.format("C: received msgs from cluster: %s", print(rc.list())); + } + + + protected JChannel create() throws Exception { + JChannel ch=new JChannel(getTestStack()); + ProtocolStack stack=ch.getProtocolStack(); + EncryptBase encrypt=createENCRYPT(); + stack.insertProtocol(encrypt, ProtocolStack.BELOW, NAKACK.class); + AUTH auth=new AUTH(); + auth.setAuthCoord(true); + auth.setAuthToken(new MD5Token("mysecret")); // .setAuthCoord(false); + stack.insertProtocol(auth, ProtocolStack.BELOW, GMS.class); + GMS gms = (GMS)stack.findProtocol(GMS.class); + gms.setJoinTimeout(1000); // .setValue("view_ack_collection_timeout", 10); + STABLE stable=((STABLE)stack.findProtocol(STABLE.class)); + stable.setDesiredAverageGossip(1000); + stable.setMaxBytes(500); + return ch; + } + + protected void printSymVersion(JChannel ... channels) { + for(JChannel ch: channels) { + ASYM_ENCRYPT encr=(ASYM_ENCRYPT)ch.getProtocolStack().findProtocol(ASYM_ENCRYPT.class); + byte[] sym_version=encr.getSymVersion(); + System.out.printf("sym-version %s: %s\n", ch.getLocalAddress(), Util.byteArrayToHexString(sym_version)); + } + } + + protected void printView(JChannel ... channels) { + for(JChannel ch: channels) + System.out.printf("%s: %s\n", ch.getLocalAddress(), ch.getView()); + } + + + // Note that setting encrypt_entire_message to true is critical here, or else some of the tests in this + // unit test would fail! + protected ASYM_ENCRYPT createENCRYPT() throws Exception { + ASYM_ENCRYPT encrypt=new ASYM_ENCRYPT(); + Properties props=new Properties(); + props.put("encrypt_entire_message", "true"); + props.put("sign_msgs", "true"); + encrypt.setProperties(props); + encrypt.init(); + return encrypt; + } + + + + protected static class CustomENCRYPT extends ASYM_ENCRYPT { + protected SecretKey key; + + protected Object handleUpEvent(Message msg, EncryptHeader hdr) { + if(hdr.getType() == EncryptHeader.SECRET_KEY_RSP) { + try { + key=decodeKey(msg.getBuffer()); + System.out.printf("received secret key %s !\n", key); + } + catch(Exception e) { + e.printStackTrace(); + } + } + return super.handleUpEvent(msg, hdr); + } + } +} diff --git a/tests/junit/org/jgroups/protocols/EncryptTest.java b/tests/junit/org/jgroups/protocols/EncryptTest.java new file mode 100644 index 00000000000..f9e66bbb895 --- /dev/null +++ b/tests/junit/org/jgroups/protocols/EncryptTest.java @@ -0,0 +1,354 @@ +package org.jgroups.protocols; + +import org.jgroups.*; +import org.jgroups.conf.ClassConfigurator; +import org.jgroups.demos.KeyStoreGenerator; +import org.jgroups.protocols.pbcast.GMS; +import org.jgroups.protocols.pbcast.NAKACK; +import org.jgroups.protocols.pbcast.NakAckHeader; +import org.jgroups.protocols.pbcast.STABLE; +import org.jgroups.stack.Protocol; +import org.jgroups.util.Buffer; +import org.jgroups.util.MyReceiver; +import org.jgroups.util.Util; + +import junit.framework.TestCase; +import javax.crypto.SecretKey; +import java.lang.reflect.Field; +import java.util.List; +import java.util.Vector; +import java.util.Properties; + +import static java.util.Arrays.asList; + + +/** + * Base class for tests {@link SYM_ENCRYPT_Test} and {@link ASYM_ENCRYPT_Test} + * @author Bela Ban + * @since 4.0 + */ + +public abstract class EncryptTest extends TestCase { + protected JChannel a,b,c,rogue; + protected MyReceiver<Message> ra, rb, rc, r_rogue; + protected String cluster_name; + + protected void setUp() throws Exception { + this.cluster_name="jgroups.ENCRYPT_TEST"; + a=create(); + a.connect(cluster_name); + a.setReceiver(ra=new MyReceiver<Message>().name("A").rawMsgs(true)); + + b=create(); + b.connect(cluster_name); + b.setReceiver(rb=new MyReceiver<Message>().name("B").rawMsgs(true)); + + c=create(); + c.connect(cluster_name); + c.setReceiver(rc=new MyReceiver<Message>().name("C").rawMsgs(true)); + + Util.waitUntilAllChannelsHaveSameSize(10000, 500, a,b,c); + rogue=createRogue(); + rogue.connect(cluster_name); + for(JChannel ch: asList(a,b,c)) + System.out.printf("%s: %s\n", ch.getLocalAddress(), ch.getView()); + System.out.println(""); + } + + protected void tearDown() throws Exception { + Util.close(c, b, a, rogue); + } + + protected abstract JChannel create() throws Exception; + protected abstract String getProtocolName(); + + + /** Tests A,B or C sending messages and their reception by everyone in cluster {A,B,C} */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testRegularMessageReception() throws Exception { + a.send(new Message(null, null, "Hello from A")); + b.send(new Message(null, null, "Hello from B")); + c.send(new Message(null, null, "Hello from C")); + for(int i=0; i < 20; i++) { + if(ra.size() == 3 && rb.size() == 3 && rc.size() == 3) + break; + stable(a,b,c); + Util.sleep(1000); + } + for(MyReceiver r: asList(ra,rb,rc)) + System.out.printf("%s: %s\n", r.name(), print(r.list())); + assertSize(3); + } + + /** Same as above, but all messages are 0-length */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testRegularMessageReceptionWithEmptyMessages() throws Exception { + a.send(new Message(null)); + b.send(new Message(null)); + c.send(new Message(null)); + for(int i=0; i < 20; i++) { + if(ra.size() == 3 && rb.size() == 3 && rc.size() == 3) + break; + stable(a,b,c); + Util.sleep(100); + } + for(MyReceiver r: asList(ra,rb,rc)) + System.out.printf("%s: %s\n", r.name(), print(r.list())); + assertSize(3); + } + + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testChecksum() throws Exception { + EncryptBase encrypt=(EncryptBase)a.getProtocolStack().findProtocol(EncryptBase.class); + + byte[] buffer="Hello world".getBytes(); + long checksum=encrypt.computeChecksum(buffer, 0, buffer.length); + byte[] checksum_array=encrypt.encryptChecksum(checksum); + + long actual_checksum=encrypt.decryptChecksum(null, checksum_array, 0, checksum_array.length); + assert checksum == actual_checksum : String.format("checksum: %d, actual: %d", checksum, actual_checksum); + } + + + /** A rogue member should not be able to join a cluster */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testRogueMemberJoin() throws Exception { + Util.close(rogue); + rogue=new JChannel(getTestStack()); + rogue.getProtocolStack().removeProtocol(getProtocolName()); + GMS gms=(GMS)rogue.getProtocolStack().findProtocol(GMS.class); + gms.setMaxJoinAttempts(1); + rogue.connect(cluster_name); + for(int i=0; i < 10; i++) { + if(a.getView().size() > 3) + break; + Util.sleep(500); + } + for(JChannel ch: asList(a,b,c)) + System.out.printf("%s: view is %s\n", ch.getLocalAddress(), ch.getView()); + for(JChannel ch: asList(a,b,c)) { + View view=ch.getView(); + assert view.size() == 3 : "view should be {A,B,C}: " + view; + } + } + + + /** Test that A,B,C do NOT receive any message sent by a rogue node which is not member of {A,B,C} */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testMessageSendingByRogue() throws Exception { + rogue.send(new Message(null, null, "message from rogue")); // tests single messages + Util.sleep(500); + for(int i=1; i <= 100; i++) // tests message batches + rogue.send(new Message(null, null, "msg #" + i + " from rogue")); + + for(int i=0; i < 10; i++) { + if(ra.size() > 0 || rb.size() > 0 || rc.size() > 0) + break; + Util.sleep(500); + } + assert ra.size() == 0 : String.format("received msgs from non-member: '%s'; this should not be the case", print(ra.list())); + assert rb.size() == 0 : String.format("received msgs from non-member: '%s'; this should not be the case", print(rb.list())); + assert rc.size() == 0 : String.format("received msgs from non-member: '%s'; this should not be the case", print(rc.list())); + } + + + /** + * R sends a message that has an encryption header and is encrypted with R's secret key (which of course is different + * from the cluster members' shared key as R doesn't know it). The cluster members should drop R's message as they + * shouldn't be able to decrypt it. + */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testMessageSendingByRogueUsingEncryption() throws Exception { + SYM_ENCRYPT encrypt=new SYM_ENCRYPT(); + Properties props=new Properties(); + props.put("keystore_name", "/tmp/ignored.keystore"); + props.put("encrypt_entire_message", "true"); + props.put("sign_msgs", "true"); + encrypt.setProperties(props); + + SecretKey secret_key=KeyStoreGenerator.createSecretKey(encrypt.getSymAlgorithm(), encrypt.getSymKeylength()); + encrypt.setSecretKey(secret_key); + encrypt.init(); + + EncryptHeader hdr=new EncryptHeader(EncryptHeader.ENCRYPT, encrypt.getSymVersion()); + Message msg=new Message(null); + msg.putHeader(encrypt.getName(), hdr); + + byte[] buf="hello from rogue".getBytes(); + byte[] encrypted_buf=encrypt.code(buf, 0, buf.length, false); + msg.setBuffer(encrypted_buf); + long checksum=encrypt.computeChecksum(encrypted_buf, 0, encrypted_buf.length); + byte[] tmp=encrypt.encryptChecksum(checksum); + hdr.setSignature(tmp); + + rogue.send(msg); + + for(int i=0; i < 10; i++) { + if(ra.size() > 0 || rb.size() > 0 || rc.size() > 0) + break; + Util.sleep(500); + } + assert ra.size() == 0 : String.format("received msgs from non-member: '%s'; this should not be the case", print(ra.list())); + assert rb.size() == 0 : String.format("received msgs from non-member: '%s'; this should not be the case", print(rb.list())); + assert rc.size() == 0 : String.format("received msgs from non-member: '%s'; this should not be the case", print(rc.list())); + } + + + /** + * Tests that the non-member does NOT receive messages from cluster {A,B,C}. The de-serialization of a message's + * payload (encrypted with the secret key of the rogue non-member) will fail, so the message is never passed up + * to the application. + */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testMessageReceptionByRogue() throws Exception { + rogue.setReceiver(r_rogue=new MyReceiver().rawMsgs(true)); + a.setReceiver(null); b.setReceiver(null); c.setReceiver(null); + a.send(new Message(null, null, "Hello from A")); + b.send(new Message(null, null, "Hello from B")); + c.send(new Message(null, null, "Hello from C")); + for(int i=0; i < 10; i++) { + // retransmissions will add dupes to rogue as it doesn't have dupe elimination, so we could have more than + // 3 messages! + if(r_rogue.size() > 0) + break; + Util.sleep(500); + } + + // the non-member may have received some cluster messages, if the encrypted messages coincidentally didn't + // cause a deserialization exception, but it will not be able to read their contents: + if(r_rogue.size() > 0) { + System.out.printf("Rogue non-member received %d message(s), but it should not be able to read deserialize " + + "the contents (this should throw exceptions below):\n", r_rogue.size()); + for(Message msg: r_rogue.list()) { + try { + String payload=(String)msg.getObject(); + assert !payload.startsWith("Hello from"); + } + catch(Exception t) { + System.out.printf("caught exception trying to de-serialize garbage payload into a string: %s\n", t); + } + }; + } + } + + + /** + * Tests the scenario where the non-member R captures a message from some cluster member in {A,B,C}, then + * increments the NAKACK seqno and resends that message. The message must not be received by {A,B,C}; + * it should be discarded. + */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testCapturingOfMessageByNonMemberAndResending() throws Exception { + rogue.setReceiver(new ReceiverAdapter() { + public void receive(Message msg) { + System.out.printf("rogue: modifying and resending msg %s, hdrs: %s\n", msg, msg.printHeaders()); + rogue.setReceiver(null); // to prevent recursive cycle + try { + NakAckHeader hdr=(NakAckHeader)msg.getHeader(NAKACK.name); + if(hdr != null) { + long seqno=hdr.seqno; + hdr.seqno = seqno+1; + } + else { + System.out.printf("Rogue was not able to get the %s header, fabricating one with seqno=50\n", NAKACK.class.getSimpleName()); + NakAckHeader hdr2=new NakAckHeader(NakAckHeader.MSG, 50); + msg.putHeader(NAKACK.name, hdr2); + } + + rogue.send(msg); + } + catch(Exception e) { + e.printStackTrace(); + } + } + }); + + a.send(new Message(null, null, "Hello world from A")); + + // everybody in {A,B,C} should receive this message, but NOT the rogue's resent message + for(int i=0; i < 10; i++) { + if(ra.size() > 1 || rb.size() > 1 || rc.size() > 1) + break; // this should NOT happen + Util.sleep(500); + } + + for(MyReceiver r: asList(ra,rb,rc)) + System.out.printf("%s: %s\n", r.name(), print(r.list())); + assert ra.size() == 1 : String.format("received msgs from non-member: '%s'; this should not be the case", print(ra.list())); + assert rb.size() == 1 : String.format("received msgs from non-member: '%s'; this should not be the case", print(rb.list())); + assert rc.size() == 1 : String.format("received msgs from non-member: '%s'; this should not be the case", print(rc.list())); + } + + + + /** + * Tests the case where a non-member installs a new view {rogue,A,B,C}, making itself the coordinator and therefore + * controlling admission of new members to the cluster etc... + */ + // @Test(groups=Global.FUNCTIONAL,singleThreaded=true) + public void testRogueViewInstallation() throws Exception { + final Address rogue_addr=rogue.getLocalAddress(); + Vector<Address> members = new Vector<Address>(); + members.add(rogue_addr); + members.add(a.getLocalAddress()); + members.add(b.getLocalAddress()); + members.add(c.getLocalAddress()); + View rogue_view=new View(rogue_addr, a.getView().getVid().getId()+1, members); + + Message view_change_msg=new Message(); + GMS.GmsHeader hdr = new GMS.GmsHeader(GMS.GmsHeader.VIEW, rogue_view); + view_change_msg.putHeader(GMS.name, hdr); + + rogue.send(view_change_msg); + + for(int i=0; i < 10; i++) { + if(a.getView().size() > 3) + break; + Util.sleep(500); + } + for(JChannel ch: asList(a,b,c)) { + View view=ch.getView(); + System.out.printf("%s: view is %s\n", ch.getLocalAddress(), view); + assert !view.containsMember(rogue_addr) : "view contains rogue member: " + view; + }; + } + + + protected static JChannel createRogue() throws Exception { + return new JChannel("SHARED_LOOPBACK"); + } + + + protected void assertSize(int expected_size) { + for(MyReceiver r: asList(ra,rb,rc)) + assert r.size() == expected_size : String.format("expected size: %d, actual size of %s: %d", expected_size, r.name(), r.size()); + } + + protected static String print(List<Message> msgs) { + StringBuilder sb=new StringBuilder(); + for(Message msg: msgs) + sb.append(msg.getObject()).append(" "); + return sb.toString(); + } + + protected static String print(byte[] buf, int offset, int length) { + StringBuilder sb=new StringBuilder("encrypted string: "); + for(int i=0; i < length; i++) { + int ch=buf[offset+i]; + sb.append(ch).append(' '); + } + return sb.toString(); + } + + + protected static void stable(JChannel ... channels) { + for(JChannel ch: channels) { + STABLE stable=(STABLE)ch.getProtocolStack().findProtocol(STABLE.class); + stable.runMessageGarbageCollection(); + } + } + + public static String getTestStack() { + return "SHARED_LOOPBACK:PING:pbcast.NAKACK:UNICAST:pbcast.STABLE:pbcast.GMS(join_timeout=1000):FRAG2(frag_size=8000)"; + } +} diff --git a/tests/junit/org/jgroups/protocols/SYM_ENCRYPT_Test.java b/tests/junit/org/jgroups/protocols/SYM_ENCRYPT_Test.java new file mode 100644 index 00000000000..193d17c236a --- /dev/null +++ b/tests/junit/org/jgroups/protocols/SYM_ENCRYPT_Test.java @@ -0,0 +1,52 @@ +package org.jgroups.protocols; + +import org.jgroups.Global; +import org.jgroups.JChannel; +import org.jgroups.protocols.pbcast.NAKACK; +import org.jgroups.stack.ProtocolStack; +import org.jgroups.util.Util; + +import java.util.Properties; + +/** + * Tests use cases for {@link SYM_ENCRYPT} described in https://issues.jboss.org/browse/JGRP-2021. + * Make sure you create the keystore before running this test (ant make-keystore). + * @author Bela Ban + * @since 4.0 + */ +public class SYM_ENCRYPT_Test extends EncryptTest { + protected static final String DEF_PWD="changeit"; + + protected String getProtocolName() + { + return "SYM_ENCRYPT"; + } + + protected JChannel create() throws Exception { + JChannel ch=new JChannel(getTestStack()); + SYM_ENCRYPT encrypt; + try { + encrypt=createENCRYPT("keystore/defaultStore.keystore", DEF_PWD); + } + catch(Throwable t) { + encrypt=createENCRYPT("defaultStore.keystore", DEF_PWD); + } + ch.getProtocolStack().insertProtocol(encrypt, ProtocolStack.BELOW, NAKACK.class); + return ch; + } + + // Note that setting encrypt_entire_message to true is critical here, or else some of the tests in this + // unit test would fail! + protected SYM_ENCRYPT createENCRYPT(String keystore_name, String store_pwd) throws Exception { + SYM_ENCRYPT encrypt=new SYM_ENCRYPT(); + Properties props=new Properties(); + props.put("keystore_name", keystore_name); + props.put("alias", "myKey"); + props.put("store_password", store_pwd); + props.put("encrypt_entire_message", "true"); + props.put("sign_msgs", "true"); + encrypt.setProperties(props); + encrypt.init(); + return encrypt; + } +}
1
8c1cb4fd7f2babffeb3c0cbc8e8066e7800d2e65
https://github.com/zopefoundation/Products.CMFCore/commit/8c1cb4fd7f2babffeb3c0cbc8e8066e7800d2e65
add failing test UNINDEX followed by REINDEX giving UNINDEX instad of REINDEX (see https://github.com/plone/Products.CMFPlone/issues/2585 for details)
diff --git a/Products/CMFCore/tests/test_CatalogIndexing.py b/Products/CMFCore/tests/test_CatalogIndexing.py index faa2773..a96f269 100644 --- a/Products/CMFCore/tests/test_CatalogIndexing.py +++ b/Products/CMFCore/tests/test_CatalogIndexing.py @@ -264,6 +264,10 @@ def testOptimizeQueuexx(self): queue.optimize() self.assertEqual(queue.getState(), [(REINDEX, 'A', [], None)]) + queue.setState([(UNINDEX, 'A', None, None), (REINDEX, 'A', [], 1)]) + queue.optimize() + self.assertEqual(queue.getState(), [(REINDEX, 'A', [], 1)]) + def testOptimizeQueueWithAttributes(self): queue = self.queue
0
85f05cc57ffa0a863d9d9b23e73acea9410b2937
https://github.com/qpdf/qpdf/commit/85f05cc57ffa0a863d9d9b23e73acea9410b2937
Detect xref pointer infinite loop (fixes #149)
diff --git a/ChangeLog b/ChangeLog index 510c6145..bd0acc2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-08-25 Jay Berkenbilt <[email protected]> + + * Detect infinite loop while finding additional xref tables. Fixes + #149. + 2017-08-22 Jay Berkenbilt <[email protected]> * 7.0.b1: release diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 27efdd55..86e798ee 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -491,8 +491,10 @@ void QPDF::read_xref(qpdf_offset_t xref_offset) { std::map<int, int> free_table; + std::set<qpdf_offset_t> visited; while (xref_offset) { + visited.insert(xref_offset); char buf[7]; memset(buf, 0, sizeof(buf)); this->m->file->seek(xref_offset, SEEK_SET); @@ -520,6 +522,10 @@ QPDF::read_xref(qpdf_offset_t xref_offset) { xref_offset = read_xrefStream(xref_offset); } + if (visited.count(xref_offset) != 0) + { + xref_offset = 0; + } } if (! this->m->trailer.isInitialized()) diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 232e421e..9ecf0005 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -221,6 +221,7 @@ my @bug_tests = ( ["141a", "/W entry size 0", 2], ["141b", "/W entry size 0", 2], ["143", "self-referential ostream", 3], + ["149", "xref prev pointer loop", 3], ); $n_tests += scalar(@bug_tests); foreach my $d (@bug_tests) diff --git a/qpdf/qtest/qpdf/issue-149.out b/qpdf/qtest/qpdf/issue-149.out new file mode 100644 index 00000000..5c473389 --- /dev/null +++ b/qpdf/qtest/qpdf/issue-149.out @@ -0,0 +1,2 @@ +WARNING: issue-149.pdf: reported number of objects (11) inconsistent with actual number of objects (7) +qpdf: operation succeeded with warnings; resulting file may have some problems diff --git a/qpdf/qtest/qpdf/issue-149.pdf b/qpdf/qtest/qpdf/issue-149.pdf new file mode 100644 index 00000000..9a2f8a88 Binary files /dev/null and b/qpdf/qtest/qpdf/issue-149.pdf differ
1
f8e7680cd61652b16d30948968adafe0d4dcdd54
https://github.com/WordPress/WordPress/commit/f8e7680cd61652b16d30948968adafe0d4dcdd54
Multisite: Use `hash_equals()` when comparing hashes to mitigate timing attacks. Fixes #37324. Built from https://develop.svn.wordpress.org/trunk@38032 git-svn-id: http://core.svn.wordpress.org/trunk@37973 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/ms-delete-site.php b/wp-admin/ms-delete-site.php index 282c3fac6168..9424ae19702b 100644 --- a/wp-admin/ms-delete-site.php +++ b/wp-admin/ms-delete-site.php @@ -16,7 +16,7 @@ wp_die(__( 'Sorry, you are not allowed to delete this site.')); if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) { - if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) { + if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) { wpmu_delete_blog( $wpdb->blogid ); wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), $current_site->site_name ) ); } else { diff --git a/wp-admin/options.php b/wp-admin/options.php index f39a0aac1acf..f319d5208e79 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -57,7 +57,7 @@ if ( ! empty($_GET[ 'adminhash' ] ) ) { $new_admin_details = get_option( 'adminhash' ); $redirect = 'options-general.php?updated=false'; - if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) { + if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details[ 'hash' ], $_GET[ 'adminhash' ] ) && !empty($new_admin_details[ 'newemail' ]) ) { update_option( 'admin_email', $new_admin_details[ 'newemail' ] ); delete_option( 'adminhash' ); delete_option( 'new_admin_email' ); diff --git a/wp-includes/version.php b/wp-includes/version.php index f74d18ed70bf..ff67ad2fd7c9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-beta2-38031'; +$wp_version = '4.6-beta2-38032'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
1
ccf5ee236f369206c4710324de6dcf935ea3dc4d
https://github.com/caolan/forms/commit/ccf5ee236f369206c4710324de6dcf935ea3dc4d
[Deps] update `qs`
diff --git a/package.json b/package.json index 3849273..5bfb66d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "is": "^3.3.0", "object-keys": "^1.1.1", "object.assign": "^4.1.0", - "qs": "^6.9.3", + "qs": "^6.9.4", "reduce": "^1.0.2", "string.prototype.trim": "^1.2.1" },
0
95a91d2a893c29fd25207b03306951083701480e
https://github.com/webbukkit/dynmap/commit/95a91d2a893c29fd25207b03306951083701480e
Add first pass of handling for DB config.php files
diff --git a/.gitignore b/.gitignore index de713cfe7..0eeb19b49 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # idea .idea/ +*.launch # we use maven! /build.xml diff --git a/DynmapCore/src/main/java/org/dynmap/DynmapCore.java b/DynmapCore/src/main/java/org/dynmap/DynmapCore.java index 44c7064e2..340278a50 100644 --- a/DynmapCore/src/main/java/org/dynmap/DynmapCore.java +++ b/DynmapCore/src/main/java/org/dynmap/DynmapCore.java @@ -123,6 +123,7 @@ private int perTickLimit = 50; // 50 ms private boolean dumpMissing = false; private static boolean migrate_chunks = false; + public boolean isInternalWebServerDisabled = false; private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */ private int fullrenderplayerlimit; /* Number of online players that will cause fullrender processing to pause */ @@ -530,6 +531,8 @@ public boolean enableCore(EnableCoreCallbacks cb) { updateplayerlimit = configuration.getInteger("updateplayerlimit", 0); /* Load sort permission nodes */ sortPermissionNodes = configuration.getStrings("player-sort-permission-nodes", null); + // Check if we are disabling the internal web server (implies external) + isInternalWebServerDisabled = configuration.getBoolean("disable-webserver", false); perTickLimit = configuration.getInteger("per-tick-time-limit", 50); if (perTickLimit < 5) perTickLimit = 5; @@ -594,7 +597,10 @@ public boolean enableCore(EnableCoreCallbacks cb) { loginRequired = configuration.getBoolean("login-required", false); - loadWebserver(); + // If not disabled, load and initialize the internal web server + if (!isInternalWebServerDisabled) { + loadWebserver(); + } enabledTriggers.clear(); List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>()); @@ -616,26 +622,26 @@ public boolean enableCore(EnableCoreCallbacks cb) { } Log.verboseinfo("Loaded " + componentManager.components.size() + " components."); - if (!configuration.getBoolean("disable-webserver", false)) { + if (!isInternalWebServerDisabled) { // If internal not disabled, we should be using it and not external startWebserver(); - if(!componentManager.isLoaded(InternalClientUpdateComponent.class)) { + if (!componentManager.isLoaded(InternalClientUpdateComponent.class)) { Log.warning("Using internal server, but " + InternalClientUpdateComponent.class.toString() + " is DISABLED!"); webserverCompConfigWarn = true; } - if(componentManager.isLoaded(JsonFileClientUpdateComponent.class)) { + if (componentManager.isLoaded(JsonFileClientUpdateComponent.class)) { Log.warning("Using internal server, but " + JsonFileClientUpdateComponent.class.toString() + " is ENABLED!"); } } else { - if(componentManager.isLoaded(InternalClientUpdateComponent.class)) { + if (componentManager.isLoaded(InternalClientUpdateComponent.class)) { Log.warning("Using external server, but " + InternalClientUpdateComponent.class.toString() + " is ENABLED!"); } - if(!componentManager.isLoaded(JsonFileClientUpdateComponent.class)) { + if (!componentManager.isLoaded(JsonFileClientUpdateComponent.class)) { Log.warning("Using external server, but " + JsonFileClientUpdateComponent.class.toString() + " is DISABLED!"); webserverCompConfigWarn = true; } } - if(webserverCompConfigWarn){ + if (webserverCompConfigWarn) { Log.warning("If the website is missing files or not loading/updating, this might be why."); Log.warning("For more info, read this: " + CompConfigWiki); webserverCompConfigWarn = false; diff --git a/DynmapCore/src/main/java/org/dynmap/storage/MapStorage.java b/DynmapCore/src/main/java/org/dynmap/storage/MapStorage.java index a54b84503..2a270bc18 100644 --- a/DynmapCore/src/main/java/org/dynmap/storage/MapStorage.java +++ b/DynmapCore/src/main/java/org/dynmap/storage/MapStorage.java @@ -195,7 +195,7 @@ public static long calculateImageHashCode(int[] buf, int off, int len) { */ public abstract String getMarkersURI(boolean login_enabled); /** - * URI to use for loading tiles (for external web server) + * URI to use for loading tiles (for external web server only) * * @param login_enabled - selects based on login security enabled * @return URI @@ -210,14 +210,14 @@ public boolean wrapStandaloneJSON(boolean login_enabled) { return login_enabled; } /** - * Get sendmessage URI + * Get sendmessage URI (for external web server only) * @return URI */ public String getSendMessageURI() { return "standalone/sendmessage.php"; } /** - * URI to use for loading configuration JSON files (for external web server) + * URI to use for loading configuration JSON files (for external web server only) * @param login_enabled - selects based on login security enabled * @return URI */ @@ -225,7 +225,7 @@ public String getConfigurationJSONURI(boolean login_enabled) { return login_enabled?"standalone/configuration.php":"standalone/dynmap_config.json?_={timestamp}"; } /** - * URI to use for loading update JSON files (for external web server) + * URI to use for loading update JSON files (for external web server only) * @param login_enabled - selects based on login security enabled * @return URI */ @@ -445,9 +445,11 @@ else if(lockcnt > 1) { public boolean wrapStandalonePHP() { return true; } + // For external web server only public String getStandaloneLoginURI() { return "standalone/login.php"; } + // For external web server only public String getStandaloneRegisterURI() { return "standalone/register.php"; } diff --git a/DynmapCore/src/main/java/org/dynmap/storage/filetree/FileTreeMapStorage.java b/DynmapCore/src/main/java/org/dynmap/storage/filetree/FileTreeMapStorage.java index 6f9ee4b7d..11b597d24 100644 --- a/DynmapCore/src/main/java/org/dynmap/storage/filetree/FileTreeMapStorage.java +++ b/DynmapCore/src/main/java/org/dynmap/storage/filetree/FileTreeMapStorage.java @@ -617,11 +617,13 @@ public String getMarkerFile(String world) { } @Override + // For external web server only public String getMarkersURI(boolean login_enabled) { return login_enabled?"standalone/markers.php?marker=":"tiles/"; } @Override + // For external web server only public String getTilesURI(boolean login_enabled) { return login_enabled?"standalone/tiles.php?tile=":"tiles/"; } diff --git a/DynmapCore/src/main/java/org/dynmap/storage/mariadb/MariaDBMapStorage.java b/DynmapCore/src/main/java/org/dynmap/storage/mariadb/MariaDBMapStorage.java index 364bd938c..6ca0acb4c 100644 --- a/DynmapCore/src/main/java/org/dynmap/storage/mariadb/MariaDBMapStorage.java +++ b/DynmapCore/src/main/java/org/dynmap/storage/mariadb/MariaDBMapStorage.java @@ -304,9 +304,14 @@ public boolean init(DynmapCore core) { } private boolean writeConfigPHP(DynmapCore core) { + File cfgfile = new File(baseStandaloneDir, "MySQL_config.php"); + if (!core.isInternalWebServerDisabled) { // If using internal server + cfgfile.delete(); // Zap file (in case we left junk from last time) + return true; + } FileWriter fw = null; try { - fw = new FileWriter(new File(baseStandaloneDir, "MySQL_config.php")); + fw = new FileWriter(cfgfile); fw.write("<?php\n$dbname = \'"); fw.write(WebAuthManager.esc(database)); fw.write("\';\n"); @@ -955,26 +960,31 @@ public String getMarkerFile(String world) { } @Override + // For external web server only public String getMarkersURI(boolean login_enabled) { return "standalone/MySQL_markers.php?marker="; } @Override + // For external web server only public String getTilesURI(boolean login_enabled) { return "standalone/MySQL_tiles.php?tile="; } @Override + // For external web server only public String getConfigurationJSONURI(boolean login_enabled) { return "standalone/MySQL_configuration.php"; // ?serverid={serverid}"; } @Override + // For external web server only public String getUpdateJSONURI(boolean login_enabled) { return "standalone/MySQL_update.php?world={world}&ts={timestamp}"; // &serverid={serverid}"; } @Override + // For external web server only public String getSendMessageURI() { return "standalone/MySQL_sendmessage.php"; } @@ -1066,16 +1076,17 @@ public boolean wrapStandalonePHP() { return false; } @Override + // For external web server only public String getStandaloneLoginURI() { return "standalone/MySQL_login.php"; } @Override + // For external web server only public String getStandaloneRegisterURI() { return "standalone/MySQL_register.php"; } @Override public void setLoginEnabled(DynmapCore core) { - writeConfigPHP(core); + writeConfigPHP(core); } - } diff --git a/DynmapCore/src/main/java/org/dynmap/storage/mysql/MySQLMapStorage.java b/DynmapCore/src/main/java/org/dynmap/storage/mysql/MySQLMapStorage.java index c3374e432..cdd069def 100644 --- a/DynmapCore/src/main/java/org/dynmap/storage/mysql/MySQLMapStorage.java +++ b/DynmapCore/src/main/java/org/dynmap/storage/mysql/MySQLMapStorage.java @@ -306,9 +306,14 @@ public boolean init(DynmapCore core) { } private boolean writeConfigPHP(DynmapCore core) { + File cfgfile = new File(baseStandaloneDir, "MySQL_config.php"); + if (!core.isInternalWebServerDisabled) { // If using internal server + cfgfile.delete(); // Zap file (in case we left junk from last time) + return true; + } FileWriter fw = null; try { - fw = new FileWriter(new File(baseStandaloneDir, "MySQL_config.php")); + fw = new FileWriter(cfgfile); fw.write("<?php\n$dbname = \'"); fw.write(WebAuthManager.esc(database)); fw.write("\';\n"); @@ -956,26 +961,31 @@ public String getMarkerFile(String world) { } @Override + // External web server only public String getMarkersURI(boolean login_enabled) { return "standalone/MySQL_markers.php?marker="; } @Override + // External web server only public String getTilesURI(boolean login_enabled) { return "standalone/MySQL_tiles.php?tile="; } @Override + // External web server only public String getConfigurationJSONURI(boolean login_enabled) { return "standalone/MySQL_configuration.php"; // ?serverid={serverid}"; } @Override + // External web server only public String getUpdateJSONURI(boolean login_enabled) { return "standalone/MySQL_update.php?world={world}&ts={timestamp}"; // &serverid={serverid}"; } @Override + // External web server only public String getSendMessageURI() { return "standalone/MySQL_sendmessage.php"; } @@ -1066,10 +1076,12 @@ public boolean wrapStandalonePHP() { return false; } @Override + // External web server only public String getStandaloneLoginURI() { return "standalone/MySQL_login.php"; } @Override + // External web server only public String getStandaloneRegisterURI() { return "standalone/MySQL_register.php"; } diff --git a/DynmapCore/src/main/java/org/dynmap/storage/postgresql/PostgreSQLMapStorage.java b/DynmapCore/src/main/java/org/dynmap/storage/postgresql/PostgreSQLMapStorage.java index c545b19df..98c2c2f05 100644 --- a/DynmapCore/src/main/java/org/dynmap/storage/postgresql/PostgreSQLMapStorage.java +++ b/DynmapCore/src/main/java/org/dynmap/storage/postgresql/PostgreSQLMapStorage.java @@ -308,9 +308,14 @@ public boolean init(DynmapCore core) { return writeConfigPHP(core); } private boolean writeConfigPHP(DynmapCore core) { + File cfgfile = new File(baseStandaloneDir, "PostgreSQL_config.php"); + if (!core.isInternalWebServerDisabled) { // If using internal server + cfgfile.delete(); // Zap file (in case we left junk from last time) + return true; + } FileWriter fw = null; try { - fw = new FileWriter(new File(baseStandaloneDir, "PostgreSQL_config.php")); + fw = new FileWriter(cfgfile); fw.write("<?php\n$dbname = \'"); fw.write(WebAuthManager.esc(database)); fw.write("\';\n"); @@ -957,26 +962,31 @@ public String getMarkerFile(String world) { } @Override + // External web server only public String getMarkersURI(boolean login_enabled) { return "standalone/PostgreSQL_markers.php?marker="; } @Override + // External web server only public String getTilesURI(boolean login_enabled) { return "standalone/PostgreSQL_tiles.php?tile="; } @Override + // External web server only public String getConfigurationJSONURI(boolean login_enabled) { return "standalone/PostgreSQL_configuration.php"; // ?serverid={serverid}"; } @Override + // External web server only public String getUpdateJSONURI(boolean login_enabled) { return "standalone/PostgreSQL_update.php?world={world}&ts={timestamp}"; // &serverid={serverid}"; } @Override + // External web server only public String getSendMessageURI() { return "standalone/PostgreSQL_sendmessage.php"; } @@ -1067,10 +1077,12 @@ public boolean wrapStandalonePHP() { return false; } @Override + // External web server only public String getStandaloneLoginURI() { return "standalone/PostgreSQL_login.php"; } @Override + // External web server only public String getStandaloneRegisterURI() { return "standalone/PostgreSQL_register.php"; } diff --git a/DynmapCore/src/main/java/org/dynmap/storage/sqllte/SQLiteMapStorage.java b/DynmapCore/src/main/java/org/dynmap/storage/sqllte/SQLiteMapStorage.java index 7e99cc2bd..a8bc94eae 100644 --- a/DynmapCore/src/main/java/org/dynmap/storage/sqllte/SQLiteMapStorage.java +++ b/DynmapCore/src/main/java/org/dynmap/storage/sqllte/SQLiteMapStorage.java @@ -915,11 +915,13 @@ public String getMarkerFile(String world) { } @Override + // External web server only public String getMarkersURI(boolean login_enabled) { return "standalone/SQLite_markers.php?marker="; } @Override + // External web server only public String getTilesURI(boolean login_enabled) { return "standalone/SQLite_tiles.php?tile="; } diff --git a/forge-1.16.2/.gitignore b/forge-1.16.2/.gitignore index 84c048a73..a27c3128b 100644 --- a/forge-1.16.2/.gitignore +++ b/forge-1.16.2/.gitignore @@ -1 +1,2 @@ /build/ +/bin diff --git a/forge-1.16.2/bin/main/META-INF/accesstransformer.cfg b/forge-1.16.2/bin/main/META-INF/accesstransformer.cfg deleted file mode 100644 index b9c90dd42..000000000 --- a/forge-1.16.2/bin/main/META-INF/accesstransformer.cfg +++ /dev/null @@ -1,3 +0,0 @@ -public net.minecraft.world.server.ChunkManager field_219251_e # loaded chunk list -public net.minecraft.world.server.ChunkManager field_219252_f # loaded chunk list -public net.minecraft.world.biome.BiomeAmbience field_235206_c_ # waterColor \ No newline at end of file diff --git a/forge-1.16.2/bin/main/META-INF/mods.toml b/forge-1.16.2/bin/main/META-INF/mods.toml deleted file mode 100644 index 28d21a893..000000000 --- a/forge-1.16.2/bin/main/META-INF/mods.toml +++ /dev/null @@ -1,25 +0,0 @@ -modLoader="javafml" -loaderVersion="[32,)" -issueTrackerURL="https://github.com/webbukkit/dynmap/issues" -[[mods]] -modId="dynmap" -version="${version}" -displayName="Dynmap" -authors="mikeprimm" -description=''' -Dynamic, Google-maps style rendered maps for your Minecraft server -''' - -[[dependencies.dynmap]] - modId="forge" - mandatory=true - versionRange="[32,)" - ordering="NONE" - # Side this dependency is applied on - BOTH, CLIENT or SERVER - side="SERVER" -[[dependencies.dynmap]] - modId="minecraft" - mandatory=true - versionRange="[1.16.1]" - ordering="NONE" - side="SERVER" diff --git a/forge-1.16.2/bin/main/configuration.txt b/forge-1.16.2/bin/main/configuration.txt deleted file mode 100644 index c66a91f3d..000000000 --- a/forge-1.16.2/bin/main/configuration.txt +++ /dev/null @@ -1,457 +0,0 @@ -# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/dynmap/ - -# All map templates are defined in the templates directory -# To use the HDMap very-low-res (2 ppb) map templates as world defaults, set value to vlowres -# The definitions of these templates are in normal-vlowres.txt, nether-vlowres.txt, and the_end-vlowres.txt -# To use the HDMap low-res (4 ppb) map templates as world defaults, set value to lowres -# The definitions of these templates are in normal-lowres.txt, nether-lowres.txt, and the_end-lowres.txt -# To use the HDMap hi-res (16 ppb) map templates (these can take a VERY long time for initial fullrender), set value to hires -# The definitions of these templates are in normal-hires.txt, nether-hires.txt, and the_end-hires.txt -# To use the HDMap low-res (4 ppb) map templates, with support for boosting resolution selectively to hi-res (16 ppb), set value to low_boost_hi -# The definitions of these templates are in normal-low_boost_hi.txt, nether-low_boost_hi.txt, and the_end-low_boost_hi.txt -# To use the HDMap hi-res (16 ppb) map templates, with support for boosting resolution selectively to vhi-res (32 ppb), set value to hi_boost_vhi -# The definitions of these templates are in normal-hi_boost_vhi.txt, nether-hi_boost_vhi.txt, and the_end-hi_boost_vhi.txt -# To use the HDMap hi-res (16 ppb) map templates, with support for boosting resolution selectively to xhi-res (64 ppb), set value to hi_boost_xhi -# The definitions of these templates are in normal-hi_boost_xhi.txt, nether-hi_boost_xhi.txt, and the_end-hi_boost_xhi.txt -deftemplatesuffix: hires - -# Map storage scheme: only uncommoent one 'type' value -# filetree: classic and default scheme: tree of files, with all map data under the directory indicated by 'tilespath' setting -# sqlite: single SQLite database file (this can get VERY BIG), located at 'dbfile' setting (default is file dynmap.db in data directory) -# mysql: MySQL database, at hostname:port in database, accessed via userid with password -storage: - # Filetree storage (standard tree of image files for maps) - type: filetree - # SQLite db for map storage (uses dbfile as storage location) - #type: sqlite - #dbfile: dynmap.db - # MySQL DB for map storage (at 'hostname':'port' in database 'database' using user 'userid' password 'password' and table prefix 'prefix' - #type: mysql - #hostname: localhost - #port: 3306 - #database: dynmap - #userid: dynmap - #password: dynmap - #prefix: "" - -components: - - class: org.dynmap.ClientConfigurationComponent - - - class: org.dynmap.InternalClientUpdateComponent - sendhealth: true - sendposition: true - allowwebchat: true - webchat-interval: 5 - hidewebchatip: false - trustclientname: false - includehiddenplayers: false - # (optional) if true, color codes in player display names are used - use-name-colors: false - # (optional) if true, player login IDs will be used for web chat when their IPs match - use-player-login-ip: true - # (optional) if use-player-login-ip is true, setting this to true will cause chat messages not matching a known player IP to be ignored - require-player-login-ip: false - # (optional) block player login IDs that are banned from chatting - block-banned-player-chat: true - # Require login for web-to-server chat (requires login-enabled: true) - webchat-requires-login: false - # If set to true, users must have dynmap.webchat permission in order to chat - webchat-permissions: false - # Limit length of single chat messages - chatlengthlimit: 256 - # # Optional - make players hidden when they are inside/underground/in shadows (#=light level: 0=full shadow,15=sky) - # hideifshadow: 4 - # # Optional - make player hidden when they are under cover (#=sky light level,0=underground,15=open to sky) - # hideifundercover: 14 - # # (Optional) if true, players that are crouching/sneaking will be hidden - hideifsneaking: false - # If true, player positions/status is protected (login with ID with dynmap.playermarkers.seeall permission required for info other than self) - protected-player-info: false - # If true, hide players with invisibility potion effects active - hide-if-invisiblity-potion: true - # If true, player names are not shown on map, chat, list - hidenames: false - #- class: org.dynmap.JsonFileClientUpdateComponent - # writeinterval: 1 - # sendhealth: true - # sendposition: true - # allowwebchat: true - # webchat-interval: 5 - # hidewebchatip: false - # includehiddenplayers: false - # use-name-colors: false - # use-player-login-ip: false - # require-player-login-ip: false - # block-banned-player-chat: true - # hideifshadow: 0 - # hideifundercover: 0 - # hideifsneaking: false - # # Require login for web-to-server chat (requires login-enabled: true) - # webchat-requires-login: false - # # If set to true, users must have dynmap.webchat permission in order to chat - # webchat-permissions: false - # # Limit length of single chat messages - # chatlengthlimit: 256 - # hide-if-invisiblity-potion: true - # hidenames: false - - - class: org.dynmap.SimpleWebChatComponent - allowchat: true - # If true, web UI users can supply name for chat using 'playername' URL parameter. 'trustclientname' must also be set true. - allowurlname: false - - # Note: this component is needed for the dmarker commands, and for the Marker API to be available to other plugins - - class: org.dynmap.MarkersComponent - type: markers - showlabel: false - enablesigns: false - # Default marker set for sign markers - default-sign-set: markers - # (optional) add spawn point markers to standard marker layer - showspawn: true - spawnicon: world - spawnlabel: "Spawn" - # (optional) layer for showing offline player's positions (for 'maxofflinetime' minutes after logoff) - showofflineplayers: false - offlinelabel: "Offline" - offlineicon: offlineuser - offlinehidebydefault: true - offlineminzoom: 0 - maxofflinetime: 30 - # (optional) layer for showing player's spawn beds - showspawnbeds: false - spawnbedlabel: "Spawn Beds" - spawnbedicon: bed - spawnbedhidebydefault: true - spawnbedminzoom: 0 - spawnbedformat: "%name%'s bed" - # (optional) Show world border (vanilla 1.8+) - showworldborder: true - worldborderlabel: "Border" - - - class: org.dynmap.ClientComponent - type: chat - allowurlname: false - - class: org.dynmap.ClientComponent - type: chatballoon - focuschatballoons: false - - class: org.dynmap.ClientComponent - type: chatbox - showplayerfaces: true - messagettl: 5 - # Optional: set number of lines in scrollable message history: if set, messagettl is not used to age out messages - #scrollback: 100 - # Optional: set maximum number of lines visible for chatbox - #visiblelines: 10 - # Optional: send push button - sendbutton: false - - class: org.dynmap.ClientComponent - type: playermarkers - showplayerfaces: true - showplayerhealth: true - # If true, show player body too (only valid if showplayerfaces=true - showplayerbody: false - # Option to make player faces small - don't use with showplayerhealth - smallplayerfaces: false - # Optional - make player faces layer hidden by default - hidebydefault: false - # Optional - ordering priority in layer menu (low goes before high - default is 0) - layerprio: 0 - # Optional - label for player marker layer (default is 'Players') - label: "Players" - - #- class: org.dynmap.ClientComponent - # type: digitalclock - - class: org.dynmap.ClientComponent - type: link - - - class: org.dynmap.ClientComponent - type: timeofdayclock - showdigitalclock: true - #showweather: true - # Mouse pointer world coordinate display - - class: org.dynmap.ClientComponent - type: coord - label: "Location" - hidey: false - show-mcr: false - show-chunk: false - - # Note: more than one logo component can be defined - #- class: org.dynmap.ClientComponent - # type: logo - # text: "Dynmap" - # #logourl: "images/block_surface.png" - # linkurl: "http://forums.bukkit.org/threads/dynmap.489/" - # # Valid positions: top-left, top-right, bottom-left, bottom-right - # position: bottom-right - - #- class: org.dynmap.ClientComponent - # type: inactive - # timeout: 1800 # in seconds (1800 seconds = 30 minutes) - # redirecturl: inactive.html - # #showmessage: 'You were inactive for too long.' - - #- class: org.dynmap.TestComponent - # stuff: "This is some configuration-value" - -# Treat hiddenplayers.txt as a whitelist for players to be shown on the map? (Default false) -display-whitelist: false - -# How often a tile gets rendered (in seconds). -renderinterval: 1 - -# How many tiles on update queue before accelerate render interval -renderacceleratethreshold: 60 - -# How often to render tiles when backlog is above renderacceleratethreshold -renderaccelerateinterval: 0.2 - -# How many update tiles to work on at once (if not defined, default is 1/2 the number of cores) -tiles-rendered-at-once: 2 - -# If true, use normal priority threads for rendering (versus low priority) - this can keep rendering -# from starving on busy Windows boxes (Linux JVMs pretty much ignore thread priority), but may result -# in more competition for CPU resources with other processes -usenormalthreadpriority: true - -# Save and restore pending tile renders - prevents their loss on server shutdown or /reload -saverestorepending: true - -# Save period for pending jobs (in seconds): periodic saving for crash recovery of jobs -save-pending-period: 900 - -# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds) -zoomoutperiod: 30 - -# Control whether zoom out tiles are validated on startup (can be needed if zoomout processing is interrupted, but can be expensive on large maps) -initial-zoomout-validate: true - -# Default delay on processing of updated tiles, in seconds. This can reduce potentially expensive re-rendering -# of frequently updated tiles (such as due to machines, pistons, quarries or other automation). Values can -# also be set on individual worlds and individual maps. -tileupdatedelay: 30 - -# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable -enabletilehash: true - -# Optional - hide ores: render as normal stone (so that they aren't revealed by maps) -#hideores: true - -# Optional - enabled BetterGrass style rendering of grass and snow block sides -#better-grass: true - -# Optional - enable smooth lighting by default on all maps supporting it (can be set per map as lighting option) -smooth-lighting: true - -# Optional - use world provider lighting table (good for custom worlds with custom lighting curves, like nether) -# false=classic Dynmap lighting curve -use-brightness-table: true - -# Optional - render specific block names using the textures and models of another block name: can be used to hide/disguise specific -# blocks (e.g. make ores look like stone, hide chests) or to provide simple support for rendering unsupported custom blocks -block-alias: -# "minecraft:quartz_ore": "stone" -# "diamond_ore": "coal_ore" - -# Default image format for HDMaps (png, jpg, jpg-q75, jpg-q80, jpg-q85, jpg-q90, jpg-q95, jpg-q100) -# Has no effect on maps with explicit format settings -image-format: jpg-q90 - -# use-generated-textures: if true, use generated textures (same as client); false is static water/lava textures -# correct-water-lighting: if true, use corrected water lighting (same as client); false is legacy water (darker) -# transparent-leaves: if true, leaves are transparent (lighting-wise): false is needed for some Spout versions that break lighting on leaf blocks -use-generated-textures: true -correct-water-lighting: true -transparent-leaves: true - -# ctm-support: if true, Connected Texture Mod (CTM) in texture packs is enabled (default) -ctm-support: true -# custom-colors-support: if true, Custom Colors in texture packs is enabled (default) -custom-colors-support: true - -# Control loading of player faces (if set to false, skins are never fetched) -#fetchskins: false - -# Control updating of player faces, once loaded (if faces are being managed by other apps or manually) -#refreshskins: false - -# Customize URL used for fetching player skins (%player% is macro for name) -skin-url: "http://skins.minecraft.net/MinecraftSkins/%player%.png" - -# Control behavior for new (1.0+) compass orientation (sunrise moved 90 degrees: east is now what used to be south) -# default is 'newrose' (preserve pre-1.0 maps, rotate rose) -# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap) -compass-mode: newnorth - -# Triggers for automatic updates : blockupdate-with-id is debug for breaking down updates by ID:meta -# To disable, set just 'none' and comment/delete the rest -render-triggers: - - blockupdate - #- blockupdate-with-id - #- lightingupdate - - chunkpopulate - - chunkgenerate - #- none - -# Title for the web page - if not specified, defaults to the server's name (unless it is the default of 'Unknown Server') -#webpage-title: "My Awesome Server Map" - -# The path where the tile-files are placed. -tilespath: web/tiles - -# The path where the web-files are located. -webpath: web - -# The path were the /dynmapexp command exports OBJ ZIP files -exportpath: export - -# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access). -# If not set, uses same setting as server in server.properties (or 0.0.0.0 if not specified) -#webserver-bindaddress: 0.0.0.0 - -# The TCP-port the webserver will listen on. -webserver-port: 8123 - -# Maximum concurrent session on internal web server - limits resources used in Bukkit server -max-sessions: 30 - -# Disables Webserver portion of Dynmap (Advanced users only) -disable-webserver: false - -# Enable/disable having the web server allow symbolic links (true=compatible with existing code, false=more secure (default)) -allow-symlinks: true - -# Enable login support -login-enabled: false -# Require login to access website (requires login-enabled: true) -login-required: false - -# Period between tile renders for fullrender, in seconds (non-zero to pace fullrenders, lessen CPU load) -timesliceinterval: 0.0 - -# Maximum chunk loads per server tick (1/20th of a second) - reducing this below 90 will impact render performance, but also will reduce server thread load -maxchunkspertick: 200 - -# Progress report interval for fullrender/radiusrender, in tiles. Must be 100 or greater -progressloginterval: 100 - -# Parallel fullrender: if defined, number of concurrent threads used for fullrender or radiusrender -# Note: setting this will result in much more intensive CPU use, some additional memory use. Caution should be used when -# setting this to equal or exceed the number of physical cores on the system. -#parallelrendercnt: 4 - -# Interval the browser should poll for updates. -updaterate: 2000 - -# If nonzero, server will pause fullrender/radiusrender processing when 'fullrenderplayerlimit' or more users are logged in -fullrenderplayerlimit: 0 -# If nonzero, server will pause update render processing when 'updateplayerlimit' or more users are logged in -updateplayerlimit: 0 -# Target limit on server thread use - msec per tick -per-tick-time-limit: 50 -# If TPS of server is below this setting, update renders processing is paused -update-min-tps: 18.0 -# If TPS of server is below this setting, full/radius renders processing is paused -fullrender-min-tps: 18.0 -# If TPS of server is below this setting, zoom out processing is paused -zoomout-min-tps: 18.0 - -showplayerfacesinmenu: true - -# Control whether players that are hidden or not on current map are grayed out (true=yes) -grayplayerswhenhidden: true - -# Set sidebaropened: 'true' to pin menu sidebar opened permanently, 'pinned' to default the sidebar to pinned, but allow it to unpin -#sidebaropened: true - -# Customized HTTP response headers - add 'id: value' pairs to all HTTP response headers (internal web server only) -#http-response-headers: -# Access-Control-Allow-Origin: "my-domain.com" -# X-Custom-Header-Of-Mine: "MyHeaderValue" - -# Trusted proxies for web server - which proxy addresses are trusted to supply valid X-Forwarded-For fields -trusted-proxies: - - "127.0.0.1" - - "0:0:0:0:0:0:0:1" - -joinmessage: "%playername% joined" -quitmessage: "%playername% quit" -spammessage: "You may only chat once every %interval% seconds." -# format for messages from web: %playername% substitutes sender ID (typically IP), %message% includes text -webmsgformat: "&color;2[WEB] %playername%: &color;f%message%" - -# Control whether layer control is presented on the UI (default is true) -showlayercontrol: true - -# Enable checking for banned IPs via banned-ips.txt (internal web server only) -check-banned-ips: true - -# Default selection when map page is loaded -defaultzoom: 0 -defaultworld: world -defaultmap: flat -# (optional) Zoom level and map to switch to when following a player, if possible -#followzoom: 3 -#followmap: surface - -# If true, make persistent record of IP addresses used by player logins, to support web IP to player matching -persist-ids-by-ip: true - -# If true, map text to cyrillic -cyrillic-support: false - -# Messages to customize -msg: - maptypes: "Map Types" - players: "Players" - chatrequireslogin: "Chat Requires Login" - chatnotallowed: "You are not permitted to send chat messages" - hiddennamejoin: "Player joined" - hiddennamequit: "Player quit" - -# URL for client configuration (only need to be tailored for proxies or other non-standard configurations) -url: - # configuration URL - #configuration: "up/configuration" - # update URL - #update: "up/world/{world}/{timestamp}" - # sendmessage URL - #sendmessage: "up/sendmessage" - # login URL - #login: "up/login" - # register URL - #register: "up/register" - # tiles base URL - #tiles: "tiles/" - # markers base URL - #markers: "tiles/" - # Snapshot cache size, in chunks -snapshotcachesize: 500 -# Snapshot cache uses soft references (true), else weak references (false) -soft-ref-cache: true - -# Player enter/exit title messages for map markers -# -# Processing period - how often to check player positions vs markers - default is 1000ms (1 second) -#enterexitperiod: 1000 -# Title message fade in time, in ticks (0.05 second intervals) - default is 10 (1/2 second) -#titleFadeIn: 10 -# Title message stay time, in ticks (0.05 second intervals) - default is 70 (3.5 seconds) -#titleStay: 70 -# Title message fade out time, in ticks (0.05 seocnd intervals) - default is 20 (1 second) -#titleFadeOut: 20 -# Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead -#enterexitUseTitle: true -# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false -#enterReplacesExits: true - -# Set to true to enable verbose startup messages - can help with debugging map configuration problems -# Set to false for a much quieter startup log -verbose: false - -# Enables debugging. -#debuggers: -# - class: org.dynmap.debug.LogDebugger -# Debug: dump blocks missing render data -dump-missing-blocks: false diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$EmptySection.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$EmptySection.class deleted file mode 100644 index 526a52f64..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$EmptySection.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$Section.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$Section.class deleted file mode 100644 index afb582374..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$Section.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$StdSection.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$StdSection.class deleted file mode 100644 index b60a5c13e..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot$StdSection.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot.class deleted file mode 100644 index b9f669d2a..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ChunkSnapshot.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ClientProxy.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ClientProxy.class deleted file mode 100644 index 05fde8f4d..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ClientProxy.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DmapCommand.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DmapCommand.class deleted file mode 100644 index 0588afbf9..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DmapCommand.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DmarkerCommand.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DmarkerCommand.class deleted file mode 100644 index e6e976de1..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DmarkerCommand.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapCommand.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapCommand.class deleted file mode 100644 index 5731f62c0..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapCommand.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapCommandHandler.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapCommandHandler.class deleted file mode 100644 index 72480e8b0..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapCommandHandler.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapExpCommand.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapExpCommand.class deleted file mode 100644 index 280ba59a3..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapExpCommand.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapMod$APICallback.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapMod$APICallback.class deleted file mode 100644 index 822a2ce1d..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapMod$APICallback.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapMod.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapMod.class deleted file mode 100644 index a67b09acc..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapMod.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$BlockUpdateRec.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$BlockUpdateRec.class deleted file mode 100644 index 5baee318a..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$BlockUpdateRec.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ChatHandler.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ChatHandler.class deleted file mode 100644 index 60cb9574d..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ChatHandler.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ChatMessage.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ChatMessage.class deleted file mode 100644 index ddbaeb65c..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ChatMessage.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgeCommandSender.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgeCommandSender.class deleted file mode 100644 index f5329fe40..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgeCommandSender.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgePlayer.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgePlayer.class deleted file mode 100644 index 211e8e38a..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgePlayer.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgeServer.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgeServer.class deleted file mode 100644 index c44fcd678..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ForgeServer.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$OurLog.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$OurLog.class deleted file mode 100644 index 6e65bdc56..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$OurLog.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$PlayerTracker.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$PlayerTracker.class deleted file mode 100644 index 86db2f5fb..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$PlayerTracker.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ProfileTexture.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ProfileTexture.class deleted file mode 100644 index 545c19f41..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$ProfileTexture.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$TaskRecord.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$TaskRecord.class deleted file mode 100644 index dc47f0f7d..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$TaskRecord.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$TexturesPayload.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$TexturesPayload.class deleted file mode 100644 index 630511c9b..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$TexturesPayload.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$WorldTracker.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$WorldTracker.class deleted file mode 100644 index c1b325f38..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin$WorldTracker.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin.class deleted file mode 100644 index f10595264..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/DynmapPlugin.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$EmptyChunk.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$EmptyChunk.class deleted file mode 100644 index 8ed91fa3a..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$EmptyChunk.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$OurEndMapIterator.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$OurEndMapIterator.class deleted file mode 100644 index 56f97d4c1..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$OurEndMapIterator.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$OurMapIterator.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$OurMapIterator.class deleted file mode 100644 index ac72eecb9..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$OurMapIterator.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$PlainChunk.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$PlainChunk.class deleted file mode 100644 index b8bf4867c..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache$PlainChunk.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache.class deleted file mode 100644 index 7f0a81b08..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeMapChunkCache.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeWorld.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeWorld.class deleted file mode 100644 index cacc711cf..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/ForgeWorld.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/Proxy.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/Proxy.class deleted file mode 100644 index 2f58c51f9..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/Proxy.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$CacheHashMap.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$CacheHashMap.class deleted file mode 100644 index 35a971dae..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$CacheHashMap.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$CacheRec.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$CacheRec.class deleted file mode 100644 index 70d47a8cc..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$CacheRec.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$SnapshotRec.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$SnapshotRec.class deleted file mode 100644 index 016035ec9..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache$SnapshotRec.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache.class deleted file mode 100644 index c29172ac5..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/SnapshotCache.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/VersionCheck$1.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/VersionCheck$1.class deleted file mode 100644 index 60beebc83..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/VersionCheck$1.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/VersionCheck.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/VersionCheck.class deleted file mode 100644 index 7b7af8276..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/VersionCheck.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/FilePermissions.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/FilePermissions.class deleted file mode 100644 index 86646aa42..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/FilePermissions.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/OpPermissions.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/OpPermissions.class deleted file mode 100644 index f15a987f2..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/OpPermissions.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/PermissionProvider.class b/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/PermissionProvider.class deleted file mode 100644 index b646d1d87..000000000 Binary files a/forge-1.16.2/bin/main/org/dynmap/forge_1_16_1/permissions/PermissionProvider.class and /dev/null differ diff --git a/forge-1.16.2/bin/main/pack.mcmeta b/forge-1.16.2/bin/main/pack.mcmeta deleted file mode 100644 index ee818eacc..000000000 --- a/forge-1.16.2/bin/main/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Dynmap resources", - "pack_format": 4 - } -} diff --git a/forge-1.16.2/bin/main/permissions.yml.example b/forge-1.16.2/bin/main/permissions.yml.example deleted file mode 100644 index a25f9adca..000000000 --- a/forge-1.16.2/bin/main/permissions.yml.example +++ /dev/null @@ -1,27 +0,0 @@ -# -# Sample permissions.yml for dynmap - trivial, flat-file based permissions for dynmap features -# To use, copy this file to dynmap/permissions.yml, and edit appropriate. File is YAML format. -# -# All operators have full permissions to all functions. -# All users receive the permissions under the 'defaultuser' section -# Specific users can be given more permissions by defining a section with their name containing their permisssions -# All permissions correspond to those documented here (https://github.com/webbukkit/dynmap/wiki/Permissions), but -# do NOT have the 'dynmap.' prefix when used here (e.g. 'dynmap.fullrender' permission is just 'fullrender' here). -# -defaultuser: - - render - - show.self - - hide.self - - sendtoweb - - stats - - marker.list - - marker.listsets - - marker.icons - - webregister - - webchat - #- marker.sign - -#playername1: -# - fullrender -# - cancelrender -# - radiusrender diff --git a/forge-1.16.3/.gitignore b/forge-1.16.3/.gitignore index 84c048a73..83ccc54d0 100644 --- a/forge-1.16.3/.gitignore +++ b/forge-1.16.3/.gitignore @@ -1 +1,2 @@ /build/ +/bin/
0
252c4cb36b4ba582f9b5b2625cd65e18ce01a1b6
https://github.com/z3APA3A/3proxy/commit/252c4cb36b4ba582f9b5b2625cd65e18ce01a1b6
set 1 for release in specs
diff --git a/scripts/rh/3proxy.spec b/scripts/rh/3proxy.spec index 1cb5a52..b765975 100644 --- a/scripts/rh/3proxy.spec +++ b/scripts/rh/3proxy.spec @@ -1,6 +1,6 @@ Name: 3proxy Version: 0.9.2 -Release: 0 +Release: 1 Summary: 3proxy tiny proxy server License: GPL/LGPL/Apache/BSD URL: https://3proxy.org/
0
ff254722a2683867fcb3e67569ffd36226c4bc62
https://github.com/teeworlds/teeworlds/commit/ff254722a2683867fcb3e67569ffd36226c4bc62
added some checks to snap handling
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index c5e1475941..fe4b27b783 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1239,7 +1239,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) pData = (const char *)Unpacker.GetRaw(PartSize); - if(Unpacker.Error()) + if(Unpacker.Error() || NumParts < 1 || NumParts > CSnapshot::MAX_PARTS || Part < 0 | Part >= NumParts || PartSize < 0 || PartSize > MAX_SNAPSHOT_PACKSIZE) return; if(GameTick >= m_CurrentRecvTick) diff --git a/src/engine/shared/snapshot.h b/src/engine/shared/snapshot.h index 07d1be6098..7438e2fa2b 100644 --- a/src/engine/shared/snapshot.h +++ b/src/engine/shared/snapshot.h @@ -31,7 +31,8 @@ class CSnapshot public: enum { - MAX_SIZE=64*1024 + MAX_PARTS = 64, + MAX_SIZE = MAX_PARTS*1024 }; void Clear() { m_DataSize = 0; m_NumItems = 0; }
1
2749b8c5b8147aa468a59503a15b6597c9e40c5f
https://github.com/eclipse/mosquitto/commit/2749b8c5b8147aa468a59503a15b6597c9e40c5f
Merge branch 'fixes'
diff --git a/CMakeLists.txt b/CMakeLists.txt index 327280badc..4650e34f1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,12 +99,14 @@ if (WITH_DLT) add_definitions("-DWITH_DLT") endif (WITH_DLT) -FIND_PACKAGE(cJSON) -if (CJSON_FOUND) - message(STATUS ${CJSON_FOUND}) -else (CJSON_FOUND) - message(STATUS "Optional dependency cJSON not found. Some features will be disabled.") -endif(CJSON_FOUND) +if (WITH_CJSON) + FIND_PACKAGE(cJSON) + if (CJSON_FOUND) + message(STATUS ${CJSON_FOUND}) + else (CJSON_FOUND) + message(STATUS "Optional dependency cJSON not found. Some features will be disabled.") + endif(CJSON_FOUND) +endif() # ======================================== # Include projects diff --git a/ChangeLog.txt b/ChangeLog.txt index 06fa2b911a..02348701a1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,9 +1,41 @@ -2.0.6 - 2021-01-xx +2.0.6 - 2021-01-28 ================== Broker: - Fix calculation of remaining length parameter for websockets clients that send fragmented packets. Closes #1974. +Broker: +- Fix potential duplicate Will messages being sent when a will delay interval + has been set. +- Fix message expiry interval property not being honoured in + `mosquitto_broker_publish` and `mosquitto_broker_publish_copy`. +- Fix websockets listeners with TLS not responding. Closes #2020. +- Add notes that libsystemd-dev or similar is needed if building with systemd + support. Closes #2019. +- Improve logging in obscure cases when a client disconnects. Closes #2017. +- Fix reloading of listeners where multiple listeners have been defined with + the same port but different bind addresses. Closes #2029. +- Fix `message_size_limit` not applying to the Will payload. Closes #2022. +- The error topic-alias-invalid was being sent if an MQTT v5 client published + a message with empty topic and topic alias set, but the topic alias hadn't + already been configured on the broker. This has been fixed to send a + protocol error, as per section 3.3.4 of the specification. +- Note in the man pages that SIGHUP reloads TLS certificates. Closes #2037. +- Fix bridges not always connecting on Windows. Closes #2043. + +Apps: +- Allow command line arguments to override config file options in + mosquitto_ctrl. Closes #2010. +- mosquitto_ctrl: produce an error when requesting a new password if both + attempts do not match. Closes #2011. + +Build: +- Fix cmake builds using `WITH_CJSON=no` not working if cJSON not found. + Closes #2026. + +Other: +- The SPDX identifiers for EDL-1.0 have been changed to BSD-3-Clause as per + The Eclipse legal documentation generator. The licenses are identical. 2.0.5 - 2021-01-11 diff --git a/README-compiling.md b/README-compiling.md index f3be9d9ab1..eb1b11dae4 100644 --- a/README-compiling.md +++ b/README-compiling.md @@ -7,6 +7,7 @@ are optional. * libwebsockets (optional, disabled by default, version 2.4 and above) * cJSON (optional but recommended, for dynamic-security plugin support, and JSON output from mosquitto_sub/mosquitto_rr) +* libsystemd-dev (optional, if building with systemd support on Linux) * On Windows, a pthreads library is required if threading support is to be included. diff --git a/apps/db_dump/db_dump.c b/apps/db_dump/db_dump.c index c0c1e05670..ad6d2f7b2d 100644 --- a/apps/db_dump/db_dump.c +++ b/apps/db_dump/db_dump.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/db_dump/db_dump.h b/apps/db_dump/db_dump.h index 862941807f..f6586aa757 100644 --- a/apps/db_dump/db_dump.h +++ b/apps/db_dump/db_dump.h @@ -12,7 +12,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/db_dump/print.c b/apps/db_dump/print.c index 10ab1d38b5..84ca2ef0e8 100644 --- a/apps/db_dump/print.c +++ b/apps/db_dump/print.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/db_dump/stubs.c b/apps/db_dump/stubs.c index 5fb08a8cb7..af00f70684 100644 --- a/apps/db_dump/stubs.c +++ b/apps/db_dump/stubs.c @@ -6,74 +6,113 @@ struct mosquitto *context__init(mosq_sock_t sock) { + UNUSED(sock); + return NULL; } int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store *stored, uint32_t message_expiry_interval, dbid_t store_id, enum mosquitto_msg_origin origin) { + UNUSED(source); + UNUSED(stored); + UNUSED(message_expiry_interval); + UNUSED(store_id); + UNUSED(origin); return 0; } void db__msg_store_ref_inc(struct mosquitto_msg_store *store) { + UNUSED(store); } int handle__packet(struct mosquitto *context) { + UNUSED(context); return 0; } int log__printf(struct mosquitto *mosq, unsigned int level, const char *fmt, ...) { + UNUSED(mosq); + UNUSED(level); + UNUSED(fmt); return 0; } FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) { + UNUSED(path); + UNUSED(mode); + UNUSED(restrict_read); return NULL; } enum mosquitto_client_state mosquitto__get_state(struct mosquitto *mosq) { + UNUSED(mosq); return mosq_cs_new; } int mux__add_out(struct mosquitto *mosq) { + UNUSED(mosq); return 0; } int mux__remove_out(struct mosquitto *mosq) { + UNUSED(mosq); return 0; } ssize_t net__read(struct mosquitto *mosq, void *buf, size_t count) { + UNUSED(mosq); + UNUSED(buf); + UNUSED(count); return 0; } ssize_t net__write(struct mosquitto *mosq, const void *buf, size_t count) { + UNUSED(mosq); + UNUSED(buf); + UNUSED(count); return 0; } int retain__store(const char *topic, struct mosquitto_msg_store *stored, char **split_topics) { + UNUSED(topic); + UNUSED(stored); + UNUSED(split_topics); return 0; } int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root) { + UNUSED(context); + UNUSED(sub); + UNUSED(qos); + UNUSED(identifier); + UNUSED(options); + UNUSED(root); return 0; } int sub__messages_queue(const char *source_id, const char *topic, uint8_t qos, int retain, struct mosquitto_msg_store **stored) { + UNUSED(source_id); + UNUSED(topic); + UNUSED(qos); + UNUSED(retain); + UNUSED(stored); return 0; } int keepalive__update(struct mosquitto *context) { + UNUSED(context); return 0; } diff --git a/apps/mosquitto_ctrl/client.c b/apps/mosquitto_ctrl/client.c index ea04e2e385..4464ce165f 100644 --- a/apps/mosquitto_ctrl/client.c +++ b/apps/mosquitto_ctrl/client.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/mosquitto_ctrl/dynsec.c b/apps/mosquitto_ctrl/dynsec.c index 796207e647..fae86f43ee 100644 --- a/apps/mosquitto_ctrl/dynsec.c +++ b/apps/mosquitto_ctrl/dynsec.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -386,6 +386,7 @@ static void dynsec__payload_callback(struct mosq_ctrl *ctrl, long payloadlen, co UNUSED(ctrl); #if CJSON_VERSION_FULL < 1007013 + UNUSED(payloadlen); tree = cJSON_Parse(payload); #else tree = cJSON_ParseWithLength(payload, payloadlen); @@ -720,9 +721,8 @@ int dynsec_init(int argc, char *argv[]) snprintf(verify_prompt, sizeof(verify_prompt), "Reenter password for %s: ", admin_user); rc = get_password(prompt, verify_prompt, false, password, sizeof(password)); if(rc){ - fprintf(stderr, "Error getting password.\n"); mosquitto_lib_cleanup(); - return 1; + return -1; } admin_password = password; } diff --git a/apps/mosquitto_ctrl/dynsec_client.c b/apps/mosquitto_ctrl/dynsec_client.c index 45b6d6af2a..ed900eff96 100644 --- a/apps/mosquitto_ctrl/dynsec_client.c +++ b/apps/mosquitto_ctrl/dynsec_client.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -65,6 +65,9 @@ int dynsec_client__create(int argc, char *argv[], cJSON *j_command) rc = get_password(prompt, verify_prompt, true, password_buf, sizeof(password_buf)); if(rc == 0){ password = password_buf; + }else if(rc == 2){ + fprintf(stderr, "Error: Passwords do not match.\n"); + return -1; }else{ password = NULL; printf("\n"); @@ -163,7 +166,7 @@ int dynsec_client__set_password(int argc, char *argv[], cJSON *j_command) snprintf(verify_prompt, sizeof(verify_prompt), "Reenter password for %s: ", username); rc = get_password(prompt, verify_prompt, false, password_buf, sizeof(password_buf)); if(rc){ - return MOSQ_ERR_INVAL; + return -1; } password = password_buf; }else{ diff --git a/apps/mosquitto_ctrl/dynsec_group.c b/apps/mosquitto_ctrl/dynsec_group.c index 5fc31b8493..742e941831 100644 --- a/apps/mosquitto_ctrl/dynsec_group.c +++ b/apps/mosquitto_ctrl/dynsec_group.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/mosquitto_ctrl/dynsec_role.c b/apps/mosquitto_ctrl/dynsec_role.c index 2bc5a03d50..14eebcaa20 100644 --- a/apps/mosquitto_ctrl/dynsec_role.c +++ b/apps/mosquitto_ctrl/dynsec_role.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/mosquitto_ctrl/example.c b/apps/mosquitto_ctrl/example.c index 1027fb607b..01b8d580dc 100644 --- a/apps/mosquitto_ctrl/example.c +++ b/apps/mosquitto_ctrl/example.c @@ -10,11 +10,13 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. */ +#include "config.h" + #include <cjson/cJSON.h> #include <stdio.h> #include <stdlib.h> @@ -31,6 +33,9 @@ void ctrl_help(void) int ctrl_main(int argc, char *argv[], struct mosq_ctrl *ctrl) { + UNUSED(argc); + UNUSED(ctrl); + if(!strcasecmp(argv[0], "help")){ ctrl_help(); return -1; diff --git a/apps/mosquitto_ctrl/mosquitto_ctrl.c b/apps/mosquitto_ctrl/mosquitto_ctrl.c index 6ee729c2c5..bda959025b 100644 --- a/apps/mosquitto_ctrl/mosquitto_ctrl.c +++ b/apps/mosquitto_ctrl/mosquitto_ctrl.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/mosquitto_ctrl/mosquitto_ctrl.h b/apps/mosquitto_ctrl/mosquitto_ctrl.h index 0c9c931a46..fce2a78d6a 100644 --- a/apps/mosquitto_ctrl/mosquitto_ctrl.h +++ b/apps/mosquitto_ctrl/mosquitto_ctrl.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/mosquitto_ctrl/options.c b/apps/mosquitto_ctrl/options.c index 8d8d3bc98b..5c36e5db6f 100644 --- a/apps/mosquitto_ctrl/options.c +++ b/apps/mosquitto_ctrl/options.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -89,11 +89,11 @@ int ctrl_config_parse(struct mosq_config *cfg, int *argc, char **argv[]) init_config(cfg); - /* Deal with real argc/argv */ - rc = client_config_line_proc(cfg, argc, argv); + rc = client_config_load(cfg); if(rc) return rc; - rc = client_config_load(cfg); + /* Deal with real argc/argv */ + rc = client_config_line_proc(cfg, argc, argv); if(rc) return rc; #ifdef WITH_TLS diff --git a/apps/mosquitto_passwd/get_password.c b/apps/mosquitto_passwd/get_password.c index a3113d1a59..a62a76cd8b 100644 --- a/apps/mosquitto_passwd/get_password.c +++ b/apps/mosquitto_passwd/get_password.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -135,7 +135,7 @@ int get_password(const char *prompt, const char *verify_prompt, bool quiet, char if(!quiet){ fprintf(stderr, "Error: Passwords do not match.\n"); } - return 1; + return 2; } } diff --git a/apps/mosquitto_passwd/get_password.h b/apps/mosquitto_passwd/get_password.h index f62afd0dba..3cada7c604 100644 --- a/apps/mosquitto_passwd/get_password.h +++ b/apps/mosquitto_passwd/get_password.h @@ -12,7 +12,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/apps/mosquitto_passwd/mosquitto_passwd.c b/apps/mosquitto_passwd/mosquitto_passwd.c index 2684688192..628bcc714f 100644 --- a/apps/mosquitto_passwd/mosquitto_passwd.c +++ b/apps/mosquitto_passwd/mosquitto_passwd.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -392,7 +392,7 @@ void handle_sigint(int signal) static bool is_username_valid(const char *username) { - int i; + size_t i; size_t slen; if(username){ diff --git a/client/client_props.c b/client/client_props.c index 0c34e3a55c..45d5052d04 100644 --- a/client/client_props.c +++ b/client/client_props.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/client/client_shared.c b/client/client_shared.c index 03d518c17c..2a9e3720f4 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -46,7 +46,7 @@ static int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int static int check_format(const char *str) { - int i; + size_t i; size_t len; len = strlen(str); @@ -1395,7 +1395,7 @@ int client_connect(struct mosquitto *mosq, struct mosq_config *cfg) /* Convert %25 -> %, %3a, %3A -> :, %40 -> @ */ static int mosquitto__urldecode(char *str) { - int i, j; + size_t i, j; size_t len; if(!str) return 0; diff --git a/client/client_shared.h b/client/client_shared.h index 8fb9c62426..156c7f6868 100644 --- a/client/client_shared.h +++ b/client/client_shared.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/client/pub_client.c b/client/pub_client.c index 9f276c6393..9153ebad25 100644 --- a/client/pub_client.c +++ b/client/pub_client.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/client/pub_shared.c b/client/pub_shared.c index 2718c4eb9c..0b9323c94e 100644 --- a/client/pub_shared.c +++ b/client/pub_shared.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -125,7 +125,7 @@ int load_file(const char *filename) return 1; } pos = 0; - while(pos < cfg.msglen){ + while(pos < (size_t)cfg.msglen){ rlen = fread(&(cfg.message[pos]), sizeof(char), (size_t )cfg.msglen-pos, fptr); pos += rlen; } diff --git a/client/pub_shared.h b/client/pub_shared.h index 023d91a9d3..9f657de49d 100644 --- a/client/pub_shared.h +++ b/client/pub_shared.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/client/rr_client.c b/client/rr_client.c index 464d735e6f..2331a4ed77 100644 --- a/client/rr_client.c +++ b/client/rr_client.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/client/sub_client.c b/client/sub_client.c index 352c469452..e2cebcdc20 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/client/sub_client_output.c b/client/sub_client_output.c index 0163b0e21b..adb432ce92 100644 --- a/client/sub_client_output.c +++ b/client/sub_client_output.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -96,6 +96,8 @@ static void write_payload(const unsigned char *payload, int payloadlen, int hex, int i; int padlen; + UNUSED(precision); /* FIXME - use or remove */ + if(field_width > 0){ if(payloadlen > field_width){ payloadlen = field_width; @@ -357,6 +359,9 @@ static int json_print(const struct mosquitto_message *message, const mosquitto_p return MOSQ_ERR_SUCCESS; #else + UNUSED(properties); + UNUSED(pretty); + strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.000000Z%z", ti); snprintf(&buf[strlen("2020-05-06T21:48:00.")], 9, "%06d", ns/1000); buf[strlen("2020-05-06T21:48:00.000000")] = 'Z'; @@ -625,7 +630,7 @@ static void formatted_print_percent(const struct mosq_config *lcfg, const struct static void formatted_print(const struct mosq_config *lcfg, const struct mosquitto_message *message, const mosquitto_property *properties) { size_t len; - int i; + size_t i; struct tm *ti = NULL; long ns = 0; char strf[3] = {0, 0 ,0}; diff --git a/client/sub_client_output.h b/client/sub_client_output.h index 17abb1dc83..9bca8b6729 100644 --- a/client/sub_client_output.h +++ b/client/sub_client_output.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/config.mk b/config.mk index 178c8baa94..73c2c6112d 100644 --- a/config.mk +++ b/config.mk @@ -59,6 +59,8 @@ WITH_SYS_TREE:=yes # Build with systemd support. If enabled, mosquitto will notify systemd after # initialization. See README in service/systemd/ for more information. +# Setting to yes means the libsystemd-dev or similar package will need to be +# installed. WITH_SYSTEMD:=no # Build with SRV lookup support. diff --git a/include/mosquitto.h b/include/mosquitto.h index cd10ea60b9..a517cf313b 100644 --- a/include/mosquitto.h +++ b/include/mosquitto.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/include/mosquitto_broker.h b/include/mosquitto_broker.h index 9768975f94..9653cab93e 100644 --- a/include/mosquitto_broker.h +++ b/include/mosquitto_broker.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/include/mosquitto_plugin.h b/include/mosquitto_plugin.h index 4199c7b339..d8a6c72caf 100644 --- a/include/mosquitto_plugin.h +++ b/include/mosquitto_plugin.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/include/mqtt_protocol.h b/include/mqtt_protocol.h index 86d7dc9958..15c4c3efe6 100644 --- a/include/mqtt_protocol.h +++ b/include/mqtt_protocol.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/actions.c b/lib/actions.c index 4f7ff01297..f260eaba16 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -92,7 +92,7 @@ int mosquitto_publish_v5(struct mosquitto *mosq, int *mid, const char *topic, in }else{ tlen = strlen(topic); if(mosquitto_validate_utf8(topic, (int)tlen)) return MOSQ_ERR_MALFORMED_UTF8; - if(payloadlen < 0 || payloadlen > MQTT_MAX_PAYLOAD) return MOSQ_ERR_PAYLOAD_SIZE; + if(payloadlen < 0 || payloadlen > (int)MQTT_MAX_PAYLOAD) return MOSQ_ERR_PAYLOAD_SIZE; if(mosquitto_pub_topic_check(topic) != MOSQ_ERR_SUCCESS){ return MOSQ_ERR_INVAL; } diff --git a/lib/alias_mosq.c b/lib/alias_mosq.c index 522a3650f3..95fbc96966 100644 --- a/lib/alias_mosq.c +++ b/lib/alias_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/alias_mosq.h b/lib/alias_mosq.h index 67e2520c1d..7df4149723 100644 --- a/lib/alias_mosq.h +++ b/lib/alias_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/callbacks.c b/lib/callbacks.c index ea770eee03..5dc50e24b1 100644 --- a/lib/callbacks.c +++ b/lib/callbacks.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/connect.c b/lib/connect.c index f566992454..196fde474c 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_auth.c b/lib/handle_auth.c index 33130ca3c3..e33d085d18 100644 --- a/lib/handle_auth.c +++ b/lib/handle_auth.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_connack.c b/lib/handle_connack.c index 7cf50952e2..6dca1395a6 100644 --- a/lib/handle_connack.c +++ b/lib/handle_connack.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_disconnect.c b/lib/handle_disconnect.c index 4d1ac479ae..a0a638db7a 100644 --- a/lib/handle_disconnect.c +++ b/lib/handle_disconnect.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_ping.c b/lib/handle_ping.c index 9009b72023..24a9e4e512 100644 --- a/lib/handle_ping.c +++ b/lib/handle_ping.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_pubackcomp.c b/lib/handle_pubackcomp.c index ed0c5dca66..5755708eb7 100644 --- a/lib/handle_pubackcomp.c +++ b/lib/handle_pubackcomp.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_publish.c b/lib/handle_publish.c index 12cced6f81..40644ef3e3 100644 --- a/lib/handle_publish.c +++ b/lib/handle_publish.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_pubrec.c b/lib/handle_pubrec.c index fc5b7cf463..b741a076b9 100644 --- a/lib/handle_pubrec.c +++ b/lib/handle_pubrec.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_pubrel.c b/lib/handle_pubrel.c index 1cd2864a32..b52e631c9d 100644 --- a/lib/handle_pubrel.c +++ b/lib/handle_pubrel.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_suback.c b/lib/handle_suback.c index 93a64e8a17..91a40e264b 100644 --- a/lib/handle_suback.c +++ b/lib/handle_suback.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/handle_unsuback.c b/lib/handle_unsuback.c index fdd255c16a..fd32d4862d 100644 --- a/lib/handle_unsuback.c +++ b/lib/handle_unsuback.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/helpers.c b/lib/helpers.c index 0514920170..3f0769251c 100644 --- a/lib/helpers.c +++ b/lib/helpers.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/logging_mosq.c b/lib/logging_mosq.c index adddc28b69..16e9e9498e 100644 --- a/lib/logging_mosq.c +++ b/lib/logging_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/logging_mosq.h b/lib/logging_mosq.h index 17b49a6040..580edb8b24 100644 --- a/lib/logging_mosq.h +++ b/lib/logging_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/loop.c b/lib/loop.c index 00b99ee3f6..bc2ba7f41c 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/memory_mosq.c b/lib/memory_mosq.c index 73f9901a32..4367197ef2 100644 --- a/lib/memory_mosq.c +++ b/lib/memory_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/memory_mosq.h b/lib/memory_mosq.h index 85d774922b..da14991354 100644 --- a/lib/memory_mosq.h +++ b/lib/memory_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/messages_mosq.c b/lib/messages_mosq.c index e0dfb3f919..ff28a91577 100644 --- a/lib/messages_mosq.c +++ b/lib/messages_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/messages_mosq.h b/lib/messages_mosq.h index 6a66a50cf3..5689b49e17 100644 --- a/lib/messages_mosq.h +++ b/lib/messages_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/misc_mosq.c b/lib/misc_mosq.c index 75b2eaac89..e7bf07840d 100644 --- a/lib/misc_mosq.c +++ b/lib/misc_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/misc_mosq.h b/lib/misc_mosq.h index 6456c02bed..233071e660 100644 --- a/lib/misc_mosq.h +++ b/lib/misc_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/mosquitto.c b/lib/mosquitto.c index 52fd30dac5..0dd4ac01fe 100644 --- a/lib/mosquitto.c +++ b/lib/mosquitto.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/mosquitto_internal.h b/lib/mosquitto_internal.h index 2d30f7e87b..04bdf92a04 100644 --- a/lib/mosquitto_internal.h +++ b/lib/mosquitto_internal.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/net_mosq.c b/lib/net_mosq.c index f1da60f857..d42d83a7cb 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -942,7 +942,7 @@ int net__socket_connect(struct mosquitto *mosq, const char *host, uint16_t port, if(rc2) return rc2; } - return MOSQ_ERR_SUCCESS; + return rc; } diff --git a/lib/net_mosq.h b/lib/net_mosq.h index 6dc2a1a42b..30342179d4 100644 --- a/lib/net_mosq.h +++ b/lib/net_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/net_mosq_ocsp.c b/lib/net_mosq_ocsp.c index 0f6c300283..84b818c863 100644 --- a/lib/net_mosq_ocsp.c +++ b/lib/net_mosq_ocsp.c @@ -11,7 +11,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Dr. Lars Voelker, BMW AG diff --git a/lib/options.c b/lib/options.c index 8fe1007d66..c7f739aabd 100644 --- a/lib/options.c +++ b/lib/options.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/packet_datatypes.c b/lib/packet_datatypes.c index 7a195d1912..e13d9489c4 100644 --- a/lib/packet_datatypes.c +++ b/lib/packet_datatypes.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/packet_mosq.c b/lib/packet_mosq.c index e576c67ca9..ebe6b6b85d 100644 --- a/lib/packet_mosq.c +++ b/lib/packet_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -215,10 +215,6 @@ int packet__write(struct mosquitto *mosq) if(!mosq) return MOSQ_ERR_INVAL; if(mosq->sock == INVALID_SOCKET) return MOSQ_ERR_NO_CONN; -#ifdef WITH_BROKER - mux__add_out(mosq); -#endif - pthread_mutex_lock(&mosq->current_out_packet_mutex); pthread_mutex_lock(&mosq->out_packet_mutex); if(mosq->out_packet && !mosq->current_out_packet){ @@ -230,6 +226,12 @@ int packet__write(struct mosquitto *mosq) } pthread_mutex_unlock(&mosq->out_packet_mutex); +#ifdef WITH_BROKER + if(mosq->current_out_packet){ + mux__add_out(mosq); + } +#endif + state = mosquitto__get_state(mosq); #if defined(WITH_TLS) && !defined(WITH_BROKER) if(state == mosq_cs_connect_pending || mosq->want_connect){ diff --git a/lib/packet_mosq.h b/lib/packet_mosq.h index cbdbb68e2e..3892179409 100644 --- a/lib/packet_mosq.h +++ b/lib/packet_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/property_mosq.c b/lib/property_mosq.c index ef8ffc8043..8a77dbe611 100644 --- a/lib/property_mosq.c +++ b/lib/property_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/property_mosq.h b/lib/property_mosq.h index c0110909f3..c913c05175 100644 --- a/lib/property_mosq.h +++ b/lib/property_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/read_handle.c b/lib/read_handle.c index 72ff7555d8..dd6a06bdcd 100644 --- a/lib/read_handle.c +++ b/lib/read_handle.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/read_handle.h b/lib/read_handle.h index b687fea3ff..3f97f90de6 100644 --- a/lib/read_handle.h +++ b/lib/read_handle.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/send_connect.c b/lib/send_connect.c index 29b29c69b8..d35cd80ebf 100644 --- a/lib/send_connect.c +++ b/lib/send_connect.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/send_disconnect.c b/lib/send_disconnect.c index 2d2d7932d6..db2efe080e 100644 --- a/lib/send_disconnect.c +++ b/lib/send_disconnect.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/send_mosq.c b/lib/send_mosq.c index da348c898c..059e760484 100644 --- a/lib/send_mosq.c +++ b/lib/send_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/send_mosq.h b/lib/send_mosq.h index 90274c67be..7ab48f1115 100644 --- a/lib/send_mosq.h +++ b/lib/send_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/send_publish.c b/lib/send_publish.c index e2cec9cfe4..1d1842a0e8 100644 --- a/lib/send_publish.c +++ b/lib/send_publish.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -42,8 +42,8 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint32_t payloadlen, const void *payload, uint8_t qos, bool retain, bool dup, const mosquitto_property *cmsg_props, const mosquitto_property *store_props, uint32_t expiry_interval) { #ifdef WITH_BROKER - size_t len; #ifdef WITH_BRIDGE + size_t len; int i; struct mosquitto__bridge_topic *cur_topic; bool match; diff --git a/lib/send_subscribe.c b/lib/send_subscribe.c index c030ee104f..a8e77545bb 100644 --- a/lib/send_subscribe.c +++ b/lib/send_subscribe.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/send_unsubscribe.c b/lib/send_unsubscribe.c index 27e612cf51..654f0ebedf 100644 --- a/lib/send_unsubscribe.c +++ b/lib/send_unsubscribe.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/socks_mosq.c b/lib/socks_mosq.c index 68ef72a622..a360d64be0 100644 --- a/lib/socks_mosq.c +++ b/lib/socks_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/socks_mosq.h b/lib/socks_mosq.h index 6a1f3368a9..d08c3c521e 100644 --- a/lib/socks_mosq.h +++ b/lib/socks_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/srv_mosq.c b/lib/srv_mosq.c index 049b6cff0e..412fc1ebe0 100644 --- a/lib/srv_mosq.c +++ b/lib/srv_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/strings_mosq.c b/lib/strings_mosq.c index b3a75bd1b4..3688650df7 100644 --- a/lib/strings_mosq.c +++ b/lib/strings_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/thread_mosq.c b/lib/thread_mosq.c index a8e5747a51..dbbda85ed6 100644 --- a/lib/thread_mosq.c +++ b/lib/thread_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/time_mosq.c b/lib/time_mosq.c index de8679b2e0..e8eb075512 100644 --- a/lib/time_mosq.c +++ b/lib/time_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/time_mosq.h b/lib/time_mosq.h index 8300289b82..175d9732bb 100644 --- a/lib/time_mosq.h +++ b/lib/time_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/tls_mosq.c b/lib/tls_mosq.c index 96f444d5b6..bddf2ec077 100644 --- a/lib/tls_mosq.c +++ b/lib/tls_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/tls_mosq.h b/lib/tls_mosq.h index 61020d4a11..479741d2f9 100644 --- a/lib/tls_mosq.h +++ b/lib/tls_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/utf8_mosq.c b/lib/utf8_mosq.c index e0c841d5ea..4a79cbd8c2 100644 --- a/lib/utf8_mosq.c +++ b/lib/utf8_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation. diff --git a/lib/util_mosq.c b/lib/util_mosq.c index 05b29ff7ba..fda69801f4 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/util_mosq.h b/lib/util_mosq.h index abb197d101..6fa60cfcd6 100644 --- a/lib/util_mosq.h +++ b/lib/util_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/util_topic.c b/lib/util_topic.c index 03917b1061..fc24f0d1cb 100644 --- a/lib/util_topic.c +++ b/lib/util_topic.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/lib/will_mosq.c b/lib/will_mosq.c index 6b5e002139..1699d4ae73 100644 --- a/lib/will_mosq.c +++ b/lib/will_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -43,7 +43,7 @@ int will__set(struct mosquitto *mosq, const char *topic, int payloadlen, const v mosquitto_property *p; if(!mosq || !topic) return MOSQ_ERR_INVAL; - if(payloadlen < 0 || payloadlen > MQTT_MAX_PAYLOAD) return MOSQ_ERR_PAYLOAD_SIZE; + if(payloadlen < 0 || payloadlen > (int)MQTT_MAX_PAYLOAD) return MOSQ_ERR_PAYLOAD_SIZE; if(payloadlen > 0 && !payload) return MOSQ_ERR_INVAL; if(mosquitto_pub_topic_check(topic)) return MOSQ_ERR_INVAL; diff --git a/lib/will_mosq.h b/lib/will_mosq.h index d7c8a19947..9bfdc572e0 100644 --- a/lib/will_mosq.h +++ b/lib/will_mosq.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/man/mosquitto.8.xml b/man/mosquitto.8.xml index e00bdd6d07..fe2b2d9d39 100644 --- a/man/mosquitto.8.xml +++ b/man/mosquitto.8.xml @@ -431,6 +431,8 @@ be reloaded without restarting. See <citerefentry><refentrytitle>mosquitto.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details.</para> + <para>If TLS certificates are in use, then mosquitto will + also reload certificate on receiving a SIGHUP.</para> </listitem> </varlistentry> <varlistentry> diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 6ea2b10fb7..cd76cd5f9c 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -1275,6 +1275,12 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S option and <option>keyfile</option> must be present to enable certificate based TLS encryption. </para> + <para> + The certificate pointed to by this option will be + reloaded when Mosquitto receives a SIGHUP signal. + This can be used to load new certificates prior to + the existing ones expiring. + </para> </listitem> </varlistentry> <varlistentry> @@ -1328,6 +1334,12 @@ openssl dhparam -out dhparam.pem 2048</programlisting> option and <option>certfile</option> must be present to enable certificate based TLS encryption. </para> + <para> + The private key pointed to by this option will be + reloaded when Mosquitto receives a SIGHUP signal. + This can be used to load new keys prior to + the existing ones expiring. + </para> </listitem> </varlistentry> <varlistentry> diff --git a/plugins/dynamic-security/acl.c b/plugins/dynamic-security/acl.c index 7aaf3f8c1f..8a57f7a9f7 100644 --- a/plugins/dynamic-security/acl.c +++ b/plugins/dynamic-security/acl.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/auth.c b/plugins/dynamic-security/auth.c index 9ca9b1327b..1f62e1fbd5 100644 --- a/plugins/dynamic-security/auth.c +++ b/plugins/dynamic-security/auth.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/clientlist.c b/plugins/dynamic-security/clientlist.c index d362a9b814..779c774c77 100644 --- a/plugins/dynamic-security/clientlist.c +++ b/plugins/dynamic-security/clientlist.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/clients.c b/plugins/dynamic-security/clients.c index de9092dd18..50eba2781b 100644 --- a/plugins/dynamic-security/clients.c +++ b/plugins/dynamic-security/clients.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/dynamic_security.h b/plugins/dynamic-security/dynamic_security.h index 57c814b837..561af50ad7 100644 --- a/plugins/dynamic-security/dynamic_security.h +++ b/plugins/dynamic-security/dynamic_security.h @@ -12,7 +12,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/grouplist.c b/plugins/dynamic-security/grouplist.c index afdc018669..2d4cf13b27 100644 --- a/plugins/dynamic-security/grouplist.c +++ b/plugins/dynamic-security/grouplist.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/groups.c b/plugins/dynamic-security/groups.c index d66e4dba6e..c4bdda14ff 100644 --- a/plugins/dynamic-security/groups.c +++ b/plugins/dynamic-security/groups.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/json_help.c b/plugins/dynamic-security/json_help.c index dd8379c9c9..e0c8178b1b 100644 --- a/plugins/dynamic-security/json_help.c +++ b/plugins/dynamic-security/json_help.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/json_help.h b/plugins/dynamic-security/json_help.h index b1b6aed03d..1bb6623a9e 100644 --- a/plugins/dynamic-security/json_help.h +++ b/plugins/dynamic-security/json_help.h @@ -12,7 +12,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/plugin.c b/plugins/dynamic-security/plugin.c index 1ee89890da..d5a8cf0610 100644 --- a/plugins/dynamic-security/plugin.c +++ b/plugins/dynamic-security/plugin.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/rolelist.c b/plugins/dynamic-security/rolelist.c index 6df19d2185..a8c93a96a8 100644 --- a/plugins/dynamic-security/rolelist.c +++ b/plugins/dynamic-security/rolelist.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/roles.c b/plugins/dynamic-security/roles.c index 5ffc911bd6..fb11677028 100644 --- a/plugins/dynamic-security/roles.c +++ b/plugins/dynamic-security/roles.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/dynamic-security/sub_matches_sub.c b/plugins/dynamic-security/sub_matches_sub.c index 797018791d..fb9139025b 100644 --- a/plugins/dynamic-security/sub_matches_sub.c +++ b/plugins/dynamic-security/sub_matches_sub.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/plugins/message-timestamp/mosquitto_message_timestamp.c b/plugins/message-timestamp/mosquitto_message_timestamp.c index 86132f42ce..ae35ff87d5 100644 --- a/plugins/message-timestamp/mosquitto_message_timestamp.c +++ b/plugins/message-timestamp/mosquitto_message_timestamp.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -28,7 +28,7 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 * * Note that this only works on Mosquitto 2.0 or later. */ - +#include "config.h" #include <stdio.h> #include <time.h> @@ -47,6 +47,9 @@ static int callback_message(int event, void *event_data, void *userdata) struct tm *ti; char time_buf[25]; + UNUSED(event); + UNUSED(userdata); + clock_gettime(CLOCK_REALTIME, &ts); ti = gmtime(&ts.tv_sec); strftime(time_buf, sizeof(time_buf), "%Y-%m-%dT%H:%M:%SZ", ti); @@ -68,11 +71,19 @@ int mosquitto_plugin_version(int supported_version_count, const int *supported_v int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count) { + UNUSED(user_data); + UNUSED(opts); + UNUSED(opt_count); + mosq_pid = identifier; return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL); } int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count) { + UNUSED(user_data); + UNUSED(opts); + UNUSED(opt_count); + return mosquitto_callback_unregister(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL); } diff --git a/plugins/payload-modification/mosquitto_payload_modification.c b/plugins/payload-modification/mosquitto_payload_modification.c index ac11e1c1ff..6af83ef585 100644 --- a/plugins/payload-modification/mosquitto_payload_modification.c +++ b/plugins/payload-modification/mosquitto_payload_modification.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/bridge.c b/src/bridge.c index 4581641878..d10d12696b 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -62,7 +62,7 @@ void bridge__start_all(void) int i; for(i=0; i<db.config->bridge_count; i++){ - if(bridge__new(&(db.config->bridges[i]))){ + if(bridge__new(&(db.config->bridges[i])) > 0){ log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Unable to connect to bridge %s.", db.config->bridges[i].name); } diff --git a/src/bridge_topic.c b/src/bridge_topic.c index fd4bd13345..dc19fda181 100644 --- a/src/bridge_topic.c +++ b/src/bridge_topic.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/conf.c b/src/conf.c index 611a62035b..33326c0c85 100644 --- a/src/conf.c +++ b/src/conf.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -1417,8 +1417,21 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct { for(i=0; i<config->listener_count; i++){ if(config->listeners[i].port == tmp_int){ - cur_listener = &config->listeners[i]; - break; + /* Now check we have a matching bind address, if defined */ + if(config->listeners[i].host){ + if(token && !strcmp(config->listeners[i].host, token)){ + /* They both have a bind address, and they match */ + cur_listener = &config->listeners[i]; + break; + } + }else{ + if(token == NULL){ + /* Neither this config nor the new config have a bind address, + * so they match. */ + cur_listener = &config->listeners[i]; + break; + } + } } } } @@ -1683,6 +1696,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct } memory__set_limit((size_t)lim); }else if(!strcmp(token, "message_size_limit")){ + log__printf(NULL, MOSQ_LOG_NOTICE, "Note: It is recommended to replace `message_size_limit` with `max_packet_size`."); if(conf__parse_int(&token, "message_size_limit", (int *)&config->message_size_limit, saveptr)) return MOSQ_ERR_INVAL; if(config->message_size_limit > MQTT_MAX_PAYLOAD){ log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid message_size_limit value (%u).", config->message_size_limit); diff --git a/src/conf_includedir.c b/src/conf_includedir.c index 4a082c23f1..5dda0a1ead 100644 --- a/src/conf_includedir.c +++ b/src/conf_includedir.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/context.c b/src/context.c index 083a07d069..d0f4d21842 100644 --- a/src/context.c +++ b/src/context.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/control.c b/src/control.c index b6fcf42381..9cef197c19 100644 --- a/src/control.c +++ b/src/control.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/database.c b/src/database.c index ebdf6ecd6d..db18b9f1c3 100644 --- a/src/database.c +++ b/src/database.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/handle_auth.c b/src/handle_auth.c index 36c3091a47..299e0a6466 100644 --- a/src/handle_auth.c +++ b/src/handle_auth.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/handle_connack.c b/src/handle_connack.c index 632212b97c..6aacb5926b 100644 --- a/src/handle_connack.c +++ b/src/handle_connack.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/handle_connect.c b/src/handle_connect.c index 5a33fdde2f..bc5c460462 100644 --- a/src/handle_connect.c +++ b/src/handle_connect.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -291,7 +291,7 @@ int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint1 } -static int will__read(struct mosquitto *context, struct mosquitto_message_all **will, uint8_t will_qos, int will_retain) +static int will__read(struct mosquitto *context, const char *client_id, struct mosquitto_message_all **will, uint8_t will_qos, int will_retain) { int rc = MOSQ_ERR_SUCCESS; size_t slen; @@ -344,6 +344,17 @@ static int will__read(struct mosquitto *context, struct mosquitto_message_all ** will_struct->msg.payloadlen = payloadlen; if(will_struct->msg.payloadlen > 0){ + if(db.config->message_size_limit && will_struct->msg.payloadlen > (int)db.config->message_size_limit){ + log__printf(NULL, MOSQ_LOG_DEBUG, "Client %s connected with too large Will payload", client_id); + if(context->protocol == mosq_p_mqtt5){ + send__connack(context, 0, MQTT_RC_PACKET_TOO_LARGE, NULL); + }else{ + send__connack(context, 0, CONNACK_REFUSED_NOT_AUTHORIZED, NULL); + } + context__disconnect(context); + rc = MOSQ_ERR_PAYLOAD_SIZE; + goto error_cleanup; + } will_struct->msg.payload = mosquitto__malloc((size_t)will_struct->msg.payloadlen); if(!will_struct->msg.payload){ rc = MOSQ_ERR_NOMEM; @@ -602,7 +613,7 @@ int handle__connect(struct mosquitto *context) } if(will){ - rc = will__read(context, &will_struct, will_qos, will_retain); + rc = will__read(context, client_id, &will_struct, will_qos, will_retain); if(rc) goto handle_connect_error; }else{ if(context->protocol == mosq_p_mqtt311 || context->protocol == mosq_p_mqtt5){ diff --git a/src/handle_disconnect.c b/src/handle_disconnect.c index 7c89f53a5b..2beb676a7a 100644 --- a/src/handle_disconnect.c +++ b/src/handle_disconnect.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/handle_publish.c b/src/handle_publish.c index c58438323c..68359b69ad 100644 --- a/src/handle_publish.c +++ b/src/handle_publish.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -186,7 +186,7 @@ int handle__publish(struct mosquitto *context) rc = alias__find(context, &msg->topic, (uint16_t)topic_alias); if(rc){ db__msg_store_free(msg); - return MOSQ_ERR_TOPIC_ALIAS_INVALID; + return MOSQ_ERR_PROTOCOL; } } } @@ -224,7 +224,7 @@ int handle__publish(struct mosquitto *context) if(msg->payloadlen){ if(db.config->message_size_limit && msg->payloadlen > db.config->message_size_limit){ log__printf(NULL, MOSQ_LOG_DEBUG, "Dropped too large PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))", context->id, dup, msg->qos, msg->retain, msg->source_mid, msg->topic, (long)msg->payloadlen); - reason_code = MQTT_RC_IMPLEMENTATION_SPECIFIC; + reason_code = MQTT_RC_PACKET_TOO_LARGE; goto process_bad_message; } msg->payload = mosquitto__malloc(msg->payloadlen+1); diff --git a/src/handle_subscribe.c b/src/handle_subscribe.c index e6e90a7b23..2a72c59723 100644 --- a/src/handle_subscribe.c +++ b/src/handle_subscribe.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/handle_unsubscribe.c b/src/handle_unsubscribe.c index 8e336f0932..2162b46529 100644 --- a/src/handle_unsubscribe.c +++ b/src/handle_unsubscribe.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/keepalive.c b/src/keepalive.c index 38ff4ff1ad..89d5c50b26 100644 --- a/src/keepalive.c +++ b/src/keepalive.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/lib_load.h b/src/lib_load.h index 886662a834..70948d7034 100644 --- a/src/lib_load.h +++ b/src/lib_load.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/logging.c b/src/logging.c index acee3a8aff..ff1a5b4d16 100644 --- a/src/logging.c +++ b/src/logging.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/loop.c b/src/loop.c index 14663c87cc..5044e7c895 100644 --- a/src/loop.c +++ b/src/loop.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -48,6 +48,7 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 #include "mosquitto_broker_internal.h" #include "memory_mosq.h" +#include "mqtt_protocol.h" #include "packet_mosq.h" #include "send_mosq.h" #include "sys_tree.h" @@ -69,7 +70,7 @@ void lws__sul_callback(struct lws_sorted_usec_list *l) static struct lws_sorted_usec_list sul; #endif -static int single_publish(struct mosquitto *context, struct mosquitto_message_v5 *msg) +static int single_publish(struct mosquitto *context, struct mosquitto_message_v5 *msg, uint32_t message_expiry) { struct mosquitto_msg_store *stored; uint16_t mid; @@ -95,7 +96,7 @@ static int single_publish(struct mosquitto *context, struct mosquitto_message_v5 msg->properties = NULL; } - if(db__message_store(context, stored, 0, 0, mosq_mo_broker)) return 1; + if(db__message_store(context, stored, message_expiry, 0, mosq_mo_broker)) return 1; if(msg->qos){ mid = mosquitto__mid_generate(context); @@ -106,20 +107,50 @@ static int single_publish(struct mosquitto *context, struct mosquitto_message_v5 } +static void read_message_expiry_interval(mosquitto_property **proplist, uint32_t *message_expiry) +{ + mosquitto_property *p, *previous = NULL; + + *message_expiry = 0; + + if(!proplist) return; + + p = *proplist; + while(p){ + if(p->identifier == MQTT_PROP_MESSAGE_EXPIRY_INTERVAL){ + *message_expiry = p->value.i32; + if(p == *proplist){ + *proplist = p->next; + }else{ + previous->next = p->next; + } + property__free(&p); + return; + + } + previous = p; + p = p->next; + } +} + void queue_plugin_msgs(void) { struct mosquitto_message_v5 *msg, *tmp; struct mosquitto *context; + uint32_t message_expiry; DL_FOREACH_SAFE(db.plugin_msgs, msg, tmp){ DL_DELETE(db.plugin_msgs, msg); + + read_message_expiry_interval(&msg->properties, &message_expiry); + if(msg->clientid){ HASH_FIND(hh_id, db.contexts_by_id, msg->clientid, strlen(msg->clientid), context); if(context){ - single_publish(context, msg); + single_publish(context, msg, message_expiry); } }else{ - db__messages_easy_queue(NULL, msg->topic, (uint8_t)msg->qos, (uint32_t)msg->payloadlen, msg->payload, msg->retain, 0, &msg->properties); + db__messages_easy_queue(NULL, msg->topic, (uint8_t)msg->qos, (uint32_t)msg->payloadlen, msg->payload, msg->retain, message_expiry, &msg->properties); } mosquitto__free(msg->topic); mosquitto__free(msg->payload); @@ -313,6 +344,9 @@ void do_disconnect(struct mosquitto *context, int reason) case MOSQ_ERR_OVERSIZE_PACKET: log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to oversize packet.", id); break; + case MOSQ_ERR_PAYLOAD_SIZE: + log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to oversize payload.", id); + break; case MOSQ_ERR_NOMEM: log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to out of memory.", id); break; @@ -322,8 +356,11 @@ void do_disconnect(struct mosquitto *context, int reason) case MOSQ_ERR_ADMINISTRATIVE_ACTION: log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s been disconnected by administrative action.", id); break; + case MOSQ_ERR_ERRNO: + log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected: %s.", id, strerror(errno)); + break; default: - log__printf(NULL, MOSQ_LOG_NOTICE, "Bad socket read/write on client %s, disconnecting.", id); + log__printf(NULL, MOSQ_LOG_NOTICE, "Bad socket read/write on client %s: %s", id, mosquitto_strerror(reason)); break; } }else{ diff --git a/src/memory_public.c b/src/memory_public.c index 198d0f14aa..e1f791e052 100644 --- a/src/memory_public.c +++ b/src/memory_public.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/mosquitto.c b/src/mosquitto.c index 53cd85f2c6..82a61d3cf7 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h index 1f6df3ccb0..5b88710f46 100644 --- a/src/mosquitto_broker_internal.h +++ b/src/mosquitto_broker_internal.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/mux.c b/src/mux.c index 7448320132..3703ad5fdf 100644 --- a/src/mux.c +++ b/src/mux.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -71,7 +71,9 @@ int mux__delete(struct mosquitto *context) int mux__handle(struct mosquitto__listener_sock *listensock, int listensock_count) { #ifdef WITH_EPOLL - return mux_epoll__handle(listensock, listensock_count); + UNUSED(listensock); + UNUSED(listensock_count); + return mux_epoll__handle(); #else return mux_poll__handle(listensock, listensock_count); #endif diff --git a/src/mux.h b/src/mux.h index 6b416c99e5..47573b455e 100644 --- a/src/mux.h +++ b/src/mux.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -26,7 +26,7 @@ int mux_epoll__add_out(struct mosquitto *context); int mux_epoll__remove_out(struct mosquitto *context); int mux_epoll__add_in(struct mosquitto *context); int mux_epoll__delete(struct mosquitto *context); -int mux_epoll__handle(struct mosquitto__listener_sock *listensock, int listensock_count); +int mux_epoll__handle(void); int mux_epoll__cleanup(void); int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_count); diff --git a/src/mux_epoll.c b/src/mux_epoll.c index 87d7669211..6b1b2e89d8 100644 --- a/src/mux_epoll.c +++ b/src/mux_epoll.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -54,6 +54,7 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 #include "mosquitto_broker_internal.h" #include "memory_mosq.h" +#include "mux.h" #include "packet_mosq.h" #include "send_mosq.h" #include "sys_tree.h" diff --git a/src/mux_poll.c b/src/mux_poll.c index 3e0977dcc5..ca61cd5c0e 100644 --- a/src/mux_poll.c +++ b/src/mux_poll.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -94,7 +94,7 @@ int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_c pollfds[i].fd = INVALID_SOCKET; } - for(i=0; i<listensock_count; i++){ + for(i=0; i<(size_t )listensock_count; i++){ pollfds[pollfd_index].fd = listensock[i].sock; pollfds[pollfd_index].events = POLLIN; pollfds[pollfd_index].revents = 0; @@ -108,7 +108,7 @@ int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_c int mux_poll__add_out(struct mosquitto *context) { - int i; + size_t i; if(!(context->events & POLLOUT)) { if(context->pollfd_index != -1){ @@ -121,9 +121,9 @@ int mux_poll__add_out(struct mosquitto *context) pollfds[i].fd = context->sock; pollfds[i].events = POLLIN | POLLOUT; pollfds[i].revents = 0; - context->pollfd_index = i; + context->pollfd_index = (int )i; if(i > pollfd_current_max){ - pollfd_current_max = (size_t )i; + pollfd_current_max = i; } break; } @@ -148,7 +148,7 @@ int mux_poll__remove_out(struct mosquitto *context) int mux_poll__add_in(struct mosquitto *context) { - int i; + size_t i; if(context->pollfd_index != -1){ pollfds[context->pollfd_index].fd = context->sock; @@ -160,9 +160,9 @@ int mux_poll__add_in(struct mosquitto *context) pollfds[i].fd = context->sock; pollfds[i].events = POLLIN; pollfds[i].revents = 0; - context->pollfd_index = i; + context->pollfd_index = (int )i; if(i > pollfd_current_max){ - pollfd_current_max = (size_t )i; + pollfd_current_max = i; } break; } diff --git a/src/net.c b/src/net.c index b18a401bbd..da5cbc14be 100644 --- a/src/net.c +++ b/src/net.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -608,13 +608,13 @@ int net__tls_load_verify(struct mosquitto__listener *listener) #ifndef WIN32 -static int net__bind_interface(struct mosquitto__listener *listener, mosq_sock_t sock, struct addrinfo *rp) +static int net__bind_interface(struct mosquitto__listener *listener, struct addrinfo *rp) { /* * This binds the listener sock to a network interface. * The use of SO_BINDTODEVICE requires root access, which we don't have, so instead - * use getifaddrs to find the interface addresses, and attempt to bind to - * the IP of the matching interface. + * use getifaddrs to find the interface addresses, and use IP of the + * matching interface in the later bind(). */ struct ifaddrs *ifaddr, *ifa; if(getifaddrs(&ifaddr) < 0){ @@ -725,7 +725,7 @@ static int net__socket_listen_tcp(struct mosquitto__listener *listener) #ifndef WIN32 if(listener->bind_interface){ - if(net__bind_interface(listener, sock, rp)){ + if(net__bind_interface(listener, rp)){ COMPAT_CLOSE(sock); freeaddrinfo(ainfo); mosquitto__free(listener->socks); diff --git a/src/password_mosq.c b/src/password_mosq.c index 62e06925b3..b8836f4510 100644 --- a/src/password_mosq.c +++ b/src/password_mosq.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/password_mosq.h b/src/password_mosq.h index 4c5b20f9f2..3a9362a3e7 100644 --- a/src/password_mosq.h +++ b/src/password_mosq.h @@ -12,7 +12,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/persist.h b/src/persist.h index 80358aadb9..21c0e679c1 100644 --- a/src/persist.h +++ b/src/persist.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/persist_read.c b/src/persist_read.c index 8d17024ff6..4fedfeaa88 100644 --- a/src/persist_read.c +++ b/src/persist_read.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/persist_read_v234.c b/src/persist_read_v234.c index 933da7df27..7f7a64f95a 100644 --- a/src/persist_read_v234.c +++ b/src/persist_read_v234.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/persist_read_v5.c b/src/persist_read_v5.c index f5e0cc5714..a6e6635127 100644 --- a/src/persist_read_v5.c +++ b/src/persist_read_v5.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/persist_write.c b/src/persist_write.c index d07c30b5fd..3ac4f4a594 100644 --- a/src/persist_write.c +++ b/src/persist_write.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/persist_write_v5.c b/src/persist_write_v5.c index 75d99ade64..3d1d8e818f 100644 --- a/src/persist_write_v5.c +++ b/src/persist_write_v5.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/plugin.c b/src/plugin.c index 34fddf264b..fae5fba202 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/plugin_debug.c b/src/plugin_debug.c index 16bdf3d584..2e88b96108 100644 --- a/src/plugin_debug.c +++ b/src/plugin_debug.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/plugin_defer.c b/src/plugin_defer.c index 1c6c7728e8..05f664fa54 100644 --- a/src/plugin_defer.c +++ b/src/plugin_defer.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/plugin_public.c b/src/plugin_public.c index 97bda32343..5df56fec0d 100644 --- a/src/plugin_public.c +++ b/src/plugin_public.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -91,6 +91,8 @@ int mosquitto_client_protocol(const struct mosquitto *client) if(client && client->wsi){ return mp_websockets; }else +#else + UNUSED(client); #endif { return mp_mqtt; diff --git a/src/property_broker.c b/src/property_broker.c index 4dc8a82d32..1a38c20406 100644 --- a/src/property_broker.c +++ b/src/property_broker.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/read_handle.c b/src/read_handle.c index dbebc1ce7e..416c32abe3 100644 --- a/src/read_handle.c +++ b/src/read_handle.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/retain.c b/src/retain.c index 40045401a1..ca9e73134b 100644 --- a/src/retain.c +++ b/src/retain.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/security.c b/src/security.c index 9bf46059e9..839ec31e85 100644 --- a/src/security.c +++ b/src/security.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/security_default.c b/src/security_default.c index 6bbe70af55..6c13cdbd76 100644 --- a/src/security_default.c +++ b/src/security_default.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -367,7 +367,7 @@ static int mosquitto_acl_check_default(int event, void *event_data, void *userda char *local_acl; struct mosquitto__acl *acl_root; bool result; - int i; + size_t i; size_t len, tlen, clen, ulen; char *s; struct mosquitto__security_options *security_opts = NULL; diff --git a/src/send_auth.c b/src/send_auth.c index 5a42de4f76..dbd0b8e8d8 100644 --- a/src/send_auth.c +++ b/src/send_auth.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/send_connack.c b/src/send_connack.c index b4c8e29d36..a4d36f7056 100644 --- a/src/send_connack.c +++ b/src/send_connack.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/send_suback.c b/src/send_suback.c index 3f4726bdf9..fb0b1409c8 100644 --- a/src/send_suback.c +++ b/src/send_suback.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/send_unsuback.c b/src/send_unsuback.c index 8e6a3880e2..5f59a0662a 100644 --- a/src/send_unsuback.c +++ b/src/send_unsuback.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/service.c b/src/service.c index 86b74c8ea0..2a438abd69 100644 --- a/src/service.c +++ b/src/service.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/session_expiry.c b/src/session_expiry.c index 03aed56535..1d2beb57c0 100644 --- a/src/session_expiry.c +++ b/src/session_expiry.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/signals.c b/src/signals.c index 71b586770d..9938996fca 100644 --- a/src/signals.c +++ b/src/signals.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/subs.c b/src/subs.c index d96cacb461..5868492441 100644 --- a/src/subs.c +++ b/src/subs.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/sys_tree.c b/src/sys_tree.c index 14eb71fb5f..5aee42dbf1 100644 --- a/src/sys_tree.c +++ b/src/sys_tree.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/sys_tree.h b/src/sys_tree.h index 71adec50f1..72f1da872d 100644 --- a/src/sys_tree.h +++ b/src/sys_tree.h @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/topic_tok.c b/src/topic_tok.c index 4e16c446e5..340e0b6f18 100644 --- a/src/topic_tok.c +++ b/src/topic_tok.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/src/websockets.c b/src/websockets.c index 66d6edd362..03dae1c970 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -625,8 +625,6 @@ static int callback_http( HASH_FIND(hh_sock, db.contexts_by_sock, &pollargs->fd, sizeof(pollargs->fd), mosq); if(mosq){ mux__delete(mosq); - }else{ - return 1; } break; @@ -641,8 +639,6 @@ static int callback_http( }else{ mux__remove_out(mosq); } - }else{ - return 1; } break; diff --git a/src/will_delay.c b/src/will_delay.c index 2fc6eb54e7..aca3b93140 100644 --- a/src/will_delay.c +++ b/src/will_delay.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. @@ -40,6 +40,10 @@ int will_delay__add(struct mosquitto *context) { struct will_delay_list *item; + if(context->will_delay_entry){ + return MOSQ_ERR_SUCCESS; + } + item = mosquitto__calloc(1, sizeof(struct will_delay_list)); if(!item) return MOSQ_ERR_NOMEM; diff --git a/src/xtreport.c b/src/xtreport.c index a3f99511d3..0875005289 100644 --- a/src/xtreport.c +++ b/src/xtreport.c @@ -10,7 +10,7 @@ The Eclipse Public License is available at and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. -SPDX-License-Identifier: EPL-2.0 OR EDL-1.0 +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause Contributors: Roger Light - initial implementation and documentation. diff --git a/test/broker/02-subpub-qos0-oversize-payload.py b/test/broker/02-subpub-qos0-oversize-payload.py new file mode 100755 index 0000000000..4e78dacfdf --- /dev/null +++ b/test/broker/02-subpub-qos0-oversize-payload.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +# Test whether message size limits apply. + +from mosq_test_helper import * + +def write_config(filename, port): + with open(filename, 'w') as f: + f.write("listener %d\n" % (port)) + f.write("allow_anonymous true\n") + f.write("message_size_limit 1\n") + +def do_test(proto_ver): + rc = 1 + mid = 53 + keepalive = 60 + connect_packet = mosq_test.gen_connect("subpub-qos0-test", keepalive=keepalive, proto_ver=proto_ver) + connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) + + subscribe_packet = mosq_test.gen_subscribe(mid, "subpub/qos0", 0, proto_ver=proto_ver) + suback_packet = mosq_test.gen_suback(mid, 0, proto_ver=proto_ver) + + connect2_packet = mosq_test.gen_connect("subpub-qos0-helper", keepalive=keepalive, proto_ver=proto_ver) + connack2_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) + + publish_packet_ok = mosq_test.gen_publish("subpub/qos0", qos=0, payload="A", proto_ver=proto_ver) + publish_packet_bad = mosq_test.gen_publish("subpub/qos0", qos=0, payload="AB", proto_ver=proto_ver) + + port = mosq_test.get_port() + conf_file = os.path.basename(__file__).replace('.py', '.conf') + write_config(conf_file, port) + + broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port) + + try: + sock = mosq_test.do_client_connect(connect_packet, connack_packet, timeout=20, port=port) + mosq_test.do_send_receive(sock, subscribe_packet, suback_packet, "suback") + + sock2 = mosq_test.do_client_connect(connect2_packet, connack2_packet, timeout=20, port=port) + sock2.send(publish_packet_ok) + mosq_test.expect_packet(sock, "publish 1", publish_packet_ok) + + # Check all is still well on the publishing client + mosq_test.do_ping(sock2) + + sock2.send(publish_packet_bad) + + # Check all is still well on the publishing client + mosq_test.do_ping(sock2) + + # The subscribing client shouldn't have received a PUBLISH + mosq_test.do_ping(sock) + rc = 0 + + sock.close() + except SyntaxError: + raise + except TypeError: + raise + except mosq_test.TestError: + pass + finally: + os.remove(conf_file) + broker.terminate() + broker.wait() + (stdo, stde) = broker.communicate() + if rc: + print(stde.decode('utf-8')) + print("proto_ver=%d" % (proto_ver)) + exit(rc) + + +do_test(proto_ver=4) +do_test(proto_ver=5) +exit(0) diff --git a/test/broker/02-subpub-qos0-topic-alias-unknown.py b/test/broker/02-subpub-qos0-topic-alias-unknown.py index cdce33ce9b..622271276a 100755 --- a/test/broker/02-subpub-qos0-topic-alias-unknown.py +++ b/test/broker/02-subpub-qos0-topic-alias-unknown.py @@ -14,7 +14,7 @@ def do_test(): props = mqtt5_props.gen_uint16_prop(mqtt5_props.PROP_TOPIC_ALIAS, 3) publish1_packet = mosq_test.gen_publish("", qos=0, payload="message", proto_ver=5, properties=props) - disconnect_packet = mosq_test.gen_disconnect(reason_code=148, proto_ver=5) + disconnect_packet = mosq_test.gen_disconnect(reason_code=mqtt5_rc.MQTT_RC_PROTOCOL_ERROR, proto_ver=5) port = mosq_test.get_port() broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port) diff --git a/test/broker/02-subpub-qos1-oversize-payload.py b/test/broker/02-subpub-qos1-oversize-payload.py new file mode 100755 index 0000000000..1787800417 --- /dev/null +++ b/test/broker/02-subpub-qos1-oversize-payload.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 + +# Test whether message size limits apply. + +from mosq_test_helper import * + +def write_config(filename, port): + with open(filename, 'w') as f: + f.write("listener %d\n" % (port)) + f.write("allow_anonymous true\n") + f.write("message_size_limit 1\n") + +def do_test(proto_ver): + rc = 1 + mid = 53 + keepalive = 60 + connect_packet = mosq_test.gen_connect("subpub-qos1-test", keepalive=keepalive, proto_ver=proto_ver) + connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) + + subscribe_packet = mosq_test.gen_subscribe(mid, "subpub/qos1", 1, proto_ver=proto_ver) + suback_packet = mosq_test.gen_suback(mid, 1, proto_ver=proto_ver) + + connect2_packet = mosq_test.gen_connect("subpub-qos1-helper", keepalive=keepalive, proto_ver=proto_ver) + connack2_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) + + mid = 1 + publish_packet_ok = mosq_test.gen_publish("subpub/qos1", mid=mid, qos=1, payload="A", proto_ver=proto_ver) + puback_packet_ok = mosq_test.gen_puback(mid=mid, proto_ver=proto_ver) + + mid = 2 + publish_packet_bad = mosq_test.gen_publish("subpub/qos1", mid=mid, qos=1, payload="AB", proto_ver=proto_ver) + if proto_ver == 5: + puback_packet_bad = mosq_test.gen_puback(reason_code=mqtt5_rc.MQTT_RC_PACKET_TOO_LARGE, mid=mid, proto_ver=proto_ver) + else: + puback_packet_bad = mosq_test.gen_puback(mid=mid, proto_ver=proto_ver) + + port = mosq_test.get_port() + conf_file = os.path.basename(__file__).replace('.py', '.conf') + write_config(conf_file, port) + + broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port) + + try: + sock = mosq_test.do_client_connect(connect_packet, connack_packet, timeout=20, port=port) + mosq_test.do_send_receive(sock, subscribe_packet, suback_packet, "suback") + + sock2 = mosq_test.do_client_connect(connect2_packet, connack2_packet, timeout=20, port=port) + mosq_test.do_send_receive(sock2, publish_packet_ok, puback_packet_ok, "puback 1") + mosq_test.expect_packet(sock, "publish 1", publish_packet_ok) + sock.send(puback_packet_ok) + + # Check all is still well on the publishing client + mosq_test.do_ping(sock2) + + mosq_test.do_send_receive(sock2, publish_packet_bad, puback_packet_bad, "puback 2") + + # The subscribing client shouldn't have received a PUBLISH + mosq_test.do_ping(sock) + rc = 0 + + sock.close() + except SyntaxError: + raise + except TypeError: + raise + except mosq_test.TestError: + pass + finally: + os.remove(conf_file) + broker.terminate() + broker.wait() + (stdo, stde) = broker.communicate() + if rc: + print(stde.decode('utf-8')) + print("proto_ver=%d" % (proto_ver)) + exit(rc) + + +do_test(proto_ver=4) +do_test(proto_ver=5) +exit(0) diff --git a/test/broker/07-will-oversize-payload.py b/test/broker/07-will-oversize-payload.py new file mode 100755 index 0000000000..319ec50918 --- /dev/null +++ b/test/broker/07-will-oversize-payload.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 + +# Test whether a client will that is too large is handled + +from mosq_test_helper import * + +def write_config(filename, port): + with open(filename, 'w') as f: + f.write("listener %d\n" % (port)) + f.write("allow_anonymous true\n") + f.write("message_size_limit 1\n") + +def do_test(proto_ver, clean_session): + rc = 1 + mid = 53 + keepalive = 60 + connect_packet = mosq_test.gen_connect("will-test", keepalive=keepalive, proto_ver=proto_ver) + connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) + + connect_packet_ok = mosq_test.gen_connect("test-helper", keepalive=keepalive, will_topic="will/qos0/test", will_payload=b"A", clean_session=clean_session, proto_ver=proto_ver, session_expiry=60) + connack_packet_ok = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) + + connect_packet_bad = mosq_test.gen_connect("test-helper", keepalive=keepalive, will_topic="will/qos0/test", will_payload=b"AB", clean_session=clean_session, proto_ver=proto_ver, session_expiry=60) + if proto_ver == 5: + connack_packet_bad = mosq_test.gen_connack(rc=mqtt5_rc.MQTT_RC_PACKET_TOO_LARGE, proto_ver=proto_ver, property_helper=False) + else: + connack_packet_bad = mosq_test.gen_connack(rc=5, proto_ver=proto_ver) + + subscribe_packet = mosq_test.gen_subscribe(mid, "will/qos0/test", 0, proto_ver=proto_ver) + suback_packet = mosq_test.gen_suback(mid, 0, proto_ver=proto_ver) + + publish_packet = mosq_test.gen_publish("will/qos0/test", qos=0, payload="A", proto_ver=proto_ver) + + port = mosq_test.get_port() + conf_file = os.path.basename(__file__).replace('.py', '.conf') + write_config(conf_file, port) + + broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port) + + try: + sock = mosq_test.do_client_connect(connect_packet, connack_packet, timeout=5, port=port) + mosq_test.do_send_receive(sock, subscribe_packet, suback_packet, "suback") + + sock2 = mosq_test.do_client_connect(connect_packet_bad, connack_packet_bad, port=port, timeout=5) + sock2.close() + + sock2 = mosq_test.do_client_connect(connect_packet_ok, connack_packet_ok, port=port, timeout=5) + sock2.close() + + mosq_test.expect_packet(sock, "publish", publish_packet) + # Check there are no more messages + mosq_test.do_ping(sock) + rc = 0 + + sock.close() + except mosq_test.TestError: + pass + finally: + os.remove(conf_file) + broker.terminate() + broker.wait() + (stdo, stde) = broker.communicate() + if rc: + print(stde.decode('utf-8')) + exit(rc) + +do_test(4, True) +do_test(4, False) +do_test(5, True) +do_test(5, False) +exit(0) diff --git a/test/broker/Makefile b/test/broker/Makefile index c139e1bea5..fcb6839dca 100644 --- a/test/broker/Makefile +++ b/test/broker/Makefile @@ -44,6 +44,7 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ./02-shared-qos0-v5.py ./02-subhier-crash.py ./02-subpub-qos0-long-topic.py + ./02-subpub-qos0-oversize-payload.py ./02-subpub-qos0-retain-as-publish.py ./02-subpub-qos0-send-retain.py ./02-subpub-qos0-subscription-id.py @@ -56,6 +57,7 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ./02-subpub-qos1-message-expiry-will.py ./02-subpub-qos1-message-expiry.py ./02-subpub-qos1-nolocal.py + ./02-subpub-qos1-oversize-payload.py ./02-subpub-qos1.py ./02-subpub-qos2-1322.py ./02-subpub-qos2-bad-puback-1.py @@ -141,6 +143,7 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ./07-will-no-flag.py ./07-will-null-topic.py ./07-will-null.py + ./07-will-oversize-payload.py ./07-will-properties.py ./07-will-qos0.py ./07-will-reconnect-1273.py diff --git a/test/broker/test.py b/test/broker/test.py index 28ecc92d2c..0514359aae 100755 --- a/test/broker/test.py +++ b/test/broker/test.py @@ -27,6 +27,7 @@ (1, './02-shared-qos0-v5.py'), (1, './02-subhier-crash.py'), (1, './02-subpub-qos0-long-topic.py'), + (1, './02-subpub-qos0-oversize-payload.py'), (1, './02-subpub-qos0-retain-as-publish.py'), (1, './02-subpub-qos0-send-retain.py'), (1, './02-subpub-qos0-subscription-id.py'), @@ -39,6 +40,7 @@ (1, './02-subpub-qos1-message-expiry-will.py'), (1, './02-subpub-qos1-message-expiry.py'), (1, './02-subpub-qos1-nolocal.py'), + (1, './02-subpub-qos1-oversize-payload.py'), (1, './02-subpub-qos1.py'), (1, './02-subpub-qos2-1322.py'), (1, './02-subpub-qos2-bad-puback-1.py'), @@ -120,6 +122,7 @@ (1, './07-will-no-flag.py'), (1, './07-will-null-topic.py'), (1, './07-will-null.py'), + (1, './07-will-oversize-payload.py'), (1, './07-will-properties.py'), (1, './07-will-qos0.py'), (1, './07-will-reconnect-1273.py'), diff --git a/test/mosq_test.py b/test/mosq_test.py index 901ece5547..52dcca0c4a 100644 --- a/test/mosq_test.py +++ b/test/mosq_test.py @@ -284,12 +284,20 @@ def to_string(packet): return s elif cmd == 0x40: # PUBACK - (cmd, rl, mid) = struct.unpack('!BBH', packet) - return "PUBACK, rl="+str(rl)+", mid="+str(mid) + if len(packet) == 5: + (cmd, rl, mid, reason_code) = struct.unpack('!BBHB', packet) + return "PUBACK, rl="+str(rl)+", mid="+str(mid)+", reason_code="+str(reason_code) + else: + (cmd, rl, mid) = struct.unpack('!BBH', packet) + return "PUBACK, rl="+str(rl)+", mid="+str(mid) elif cmd == 0x50: # PUBREC - (cmd, rl, mid) = struct.unpack('!BBH', packet) - return "PUBREC, rl="+str(rl)+", mid="+str(mid) + if len(packet) == 5: + (cmd, rl, mid, reason_code) = struct.unpack('!BBHB', packet) + return "PUBREC, rl="+str(rl)+", mid="+str(mid)+", reason_code="+str(reason_code) + else: + (cmd, rl, mid) = struct.unpack('!BBH', packet) + return "PUBREC, rl="+str(rl)+", mid="+str(mid) elif cmd == 0x60: # PUBREL dup = (packet0 & 0x08)>>3 @@ -353,8 +361,12 @@ def to_string(packet): return "PINGRESP, rl="+str(rl) elif cmd == 0xE0: # DISCONNECT - (cmd, rl) = struct.unpack('!BB', packet) - return "DISCONNECT, rl="+str(rl) + if len(packet) == 3: + (cmd, rl, reason_code) = struct.unpack('!BBB', packet) + return "DISCONNECT, rl="+str(rl)+", reason_code="+str(reason_code) + else: + (cmd, rl) = struct.unpack('!BB', packet) + return "DISCONNECT, rl="+str(rl) elif cmd == 0xF0: # AUTH (cmd, rl) = struct.unpack('!BB', packet) diff --git a/test/unit/bridge_topic_test.c b/test/unit/bridge_topic_test.c index 14992af8b2..03907ba416 100644 --- a/test/unit/bridge_topic_test.c +++ b/test/unit/bridge_topic_test.c @@ -101,6 +101,9 @@ int main(int argc, char *argv[]) { unsigned int fails; + UNUSED(argc); + UNUSED(argv); + if(CU_initialize_registry() != CUE_SUCCESS){ printf("Error initializing CUnit registry.\n"); return 1; diff --git a/test/unit/persist_read_stubs.c b/test/unit/persist_read_stubs.c index afe75986d6..62b03567c2 100644 --- a/test/unit/persist_read_stubs.c +++ b/test/unit/persist_read_stubs.c @@ -18,6 +18,8 @@ struct mosquitto *context__init(mosq_sock_t sock) { struct mosquitto *m; + UNUSED(sock); + m = mosquitto__calloc(1, sizeof(struct mosquitto)); if(m){ m->msgs_in.inflight_maximum = 20; @@ -50,6 +52,8 @@ int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store { int rc = MOSQ_ERR_SUCCESS; + UNUSED(origin); + if(source && source->id){ stored->source_id = mosquitto__strdup(source->id); }else{ @@ -98,6 +102,10 @@ int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...) { + UNUSED(mosq); + UNUSED(priority); + UNUSED(fmt); + return 0; } @@ -108,27 +116,45 @@ time_t mosquitto_time(void) int net__socket_close(struct mosquitto *mosq) { + UNUSED(mosq); + return MOSQ_ERR_SUCCESS; } int send__pingreq(struct mosquitto *mosq) { + UNUSED(mosq); + return MOSQ_ERR_SUCCESS; } int mosquitto_acl_check(struct mosquitto *context, const char *topic, uint32_t payloadlen, void* payload, uint8_t qos, bool retain, int access) { + UNUSED(context); + UNUSED(topic); + UNUSED(payloadlen); + UNUSED(payload); + UNUSED(qos); + UNUSED(retain); + UNUSED(access); + return MOSQ_ERR_SUCCESS; } int acl__find_acls(struct mosquitto *context) { + UNUSED(context); + return MOSQ_ERR_SUCCESS; } int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root) { + UNUSED(context); + UNUSED(options); + UNUSED(root); + last_sub = strdup(sub); last_qos = qos; last_identifier = identifier; @@ -138,11 +164,21 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i int db__message_insert(struct mosquitto *context, uint16_t mid, enum mosquitto_msg_direction dir, uint8_t qos, bool retain, struct mosquitto_msg_store *stored, mosquitto_property *properties, bool update) { + UNUSED(context); + UNUSED(mid); + UNUSED(dir); + UNUSED(qos); + UNUSED(retain); + UNUSED(stored); + UNUSED(properties); + UNUSED(update); + return MOSQ_ERR_SUCCESS; } void db__msg_store_ref_dec(struct mosquitto_msg_store **store) { + UNUSED(store); } void db__msg_store_ref_inc(struct mosquitto_msg_store *store) diff --git a/test/unit/persist_read_test.c b/test/unit/persist_read_test.c index 0055ba9470..2bac2d4460 100644 --- a/test/unit/persist_read_test.c +++ b/test/unit/persist_read_test.c @@ -832,6 +832,9 @@ int main(int argc, char *argv[]) { unsigned int fails; + UNUSED(argc); + UNUSED(argv); + if(CU_initialize_registry() != CUE_SUCCESS){ printf("Error initializing CUnit registry.\n"); return 1; diff --git a/test/unit/persist_write_stubs.c b/test/unit/persist_write_stubs.c index 59eb9d6c64..173cd4ea27 100644 --- a/test/unit/persist_write_stubs.c +++ b/test/unit/persist_write_stubs.c @@ -15,11 +15,17 @@ extern int last_qos; struct mosquitto *context__init(mosq_sock_t sock) { + UNUSED(sock); + return mosquitto__calloc(1, sizeof(struct mosquitto)); } int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...) { + UNUSED(mosq); + UNUSED(priority); + UNUSED(fmt); + return 0; } @@ -30,41 +36,80 @@ time_t mosquitto_time(void) int net__socket_close(struct mosquitto *mosq) { + UNUSED(mosq); + return MOSQ_ERR_SUCCESS; } int send__pingreq(struct mosquitto *mosq) { + UNUSED(mosq); + return MOSQ_ERR_SUCCESS; } int mosquitto_acl_check(struct mosquitto *context, const char *topic, uint32_t payloadlen, void* payload, uint8_t qos, bool retain, int access) { + UNUSED(context); + UNUSED(topic); + UNUSED(payloadlen); + UNUSED(payload); + UNUSED(qos); + UNUSED(retain); + UNUSED(access); + return MOSQ_ERR_SUCCESS; } int acl__find_acls(struct mosquitto *context) { + UNUSED(context); + return MOSQ_ERR_SUCCESS; } int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint32_t payloadlen, const void *payload, uint8_t qos, bool retain, bool dup, const mosquitto_property *cmsg_props, const mosquitto_property *store_props, uint32_t expiry_interval) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(topic); + UNUSED(payloadlen); + UNUSED(payload); + UNUSED(qos); + UNUSED(retain); + UNUSED(dup); + UNUSED(cmsg_props); + UNUSED(store_props); + UNUSED(expiry_interval); + return MOSQ_ERR_SUCCESS; } int send__pubcomp(struct mosquitto *mosq, uint16_t mid, const mosquitto_property *properties) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(properties); + return MOSQ_ERR_SUCCESS; } int send__pubrec(struct mosquitto *mosq, uint16_t mid, uint8_t reason_code, const mosquitto_property *properties) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(reason_code); + UNUSED(properties); + return MOSQ_ERR_SUCCESS; } int send__pubrel(struct mosquitto *mosq, uint16_t mid, const mosquitto_property *properties) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(properties); + return MOSQ_ERR_SUCCESS; } diff --git a/test/unit/persist_write_test.c b/test/unit/persist_write_test.c index 099027b709..abdc455f39 100644 --- a/test/unit/persist_write_test.c +++ b/test/unit/persist_write_test.c @@ -349,6 +349,9 @@ int main(int argc, char *argv[]) CU_pSuite test_suite = NULL; unsigned int fails; + UNUSED(argc); + UNUSED(argv); + if(CU_initialize_registry() != CUE_SUCCESS){ printf("Error initializing CUnit registry.\n"); return 1; diff --git a/test/unit/property_write.c b/test/unit/property_write.c index bbda06d420..ad03731643 100644 --- a/test/unit/property_write.c +++ b/test/unit/property_write.c @@ -317,6 +317,8 @@ static void varint_prop_write_helper( memset(&packet, 0, sizeof(struct mosquitto__packet)); packet.remaining_length = property__get_length_all(&property)+1; + CU_ASSERT_EQUAL(packet.remaining_length, remaining_length); + packet.packet_length = packet.remaining_length+10; packet.payload = calloc(packet.remaining_length+10, 1); diff --git a/test/unit/stubs.c b/test/unit/stubs.c index 897cd77b54..23fa36fd1e 100644 --- a/test/unit/stubs.c +++ b/test/unit/stubs.c @@ -1,3 +1,5 @@ +#include "config.h" + #include <time.h> #include <logging_mosq.h> @@ -7,6 +9,10 @@ struct mosquitto_db{ int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...) { + UNUSED(mosq); + UNUSED(priority); + UNUSED(fmt); + return 0; } @@ -17,11 +23,16 @@ time_t mosquitto_time(void) int net__socket_close(struct mosquitto_db *db, struct mosquitto *mosq) { + UNUSED(db); + UNUSED(mosq); + return MOSQ_ERR_SUCCESS; } int send__pingreq(struct mosquitto *mosq) { + UNUSED(mosq); + return MOSQ_ERR_SUCCESS; } diff --git a/test/unit/subs_stubs.c b/test/unit/subs_stubs.c index b7563745ae..0815e4a9b3 100644 --- a/test/unit/subs_stubs.c +++ b/test/unit/subs_stubs.c @@ -37,6 +37,10 @@ void db__msg_store_ref_inc(struct mosquitto_msg_store *store) int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...) { + UNUSED(mosq); + UNUSED(priority); + UNUSED(fmt); + return 0; } @@ -70,26 +74,59 @@ int acl__find_acls(struct mosquitto *context) int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint32_t payloadlen, const void *payload, uint8_t qos, bool retain, bool dup, const mosquitto_property *cmsg_props, const mosquitto_property *store_props, uint32_t expiry_interval) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(topic); + UNUSED(payloadlen); + UNUSED(payload); + UNUSED(qos); + UNUSED(retain); + UNUSED(dup); + UNUSED(cmsg_props); + UNUSED(store_props); + UNUSED(expiry_interval); + return MOSQ_ERR_SUCCESS; } int send__pubcomp(struct mosquitto *mosq, uint16_t mid, const mosquitto_property *properties) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(properties); + return MOSQ_ERR_SUCCESS; } int send__pubrec(struct mosquitto *mosq, uint16_t mid, uint8_t reason_code, const mosquitto_property *properties) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(reason_code); + UNUSED(properties); + return MOSQ_ERR_SUCCESS; } int send__pubrel(struct mosquitto *mosq, uint16_t mid, const mosquitto_property *properties) { + UNUSED(mosq); + UNUSED(mid); + UNUSED(properties); + return MOSQ_ERR_SUCCESS; } int mosquitto_acl_check(struct mosquitto *context, const char *topic, uint32_t payloadlen, void* payload, uint8_t qos, bool retain, int access) { + UNUSED(context); + UNUSED(topic); + UNUSED(payloadlen); + UNUSED(payload); + UNUSED(qos); + UNUSED(retain); + UNUSED(access); + return MOSQ_ERR_SUCCESS; } @@ -97,16 +134,24 @@ uint16_t mosquitto__mid_generate(struct mosquitto *mosq) { static uint16_t mid = 1; + UNUSED(mosq); + return ++mid; } int mosquitto_property_add_varint(mosquitto_property **proplist, int identifier, uint32_t value) { + UNUSED(proplist); + UNUSED(identifier); + UNUSED(value); + return MOSQ_ERR_SUCCESS; } int persist__backup(bool shutdown) { + UNUSED(shutdown); + return MOSQ_ERR_SUCCESS; } @@ -117,6 +162,7 @@ int persist__restore(void) void mosquitto_property_free_all(mosquitto_property **properties) { + UNUSED(properties); } int retain__init(void) @@ -126,15 +172,25 @@ int retain__init(void) void retain__clean(struct mosquitto__retainhier **retainhier) { + UNUSED(retainhier); } int retain__queue(struct mosquitto *context, const char *sub, uint8_t sub_qos, uint32_t subscription_identifier) { + UNUSED(context); + UNUSED(sub); + UNUSED(sub_qos); + UNUSED(subscription_identifier); + return MOSQ_ERR_SUCCESS; } int retain__store(const char *topic, struct mosquitto_msg_store *stored, char **split_topics) { + UNUSED(topic); + UNUSED(stored); + UNUSED(split_topics); + return MOSQ_ERR_SUCCESS; } diff --git a/test/unit/subs_test.c b/test/unit/subs_test.c index 527f499138..a596e8bc96 100644 --- a/test/unit/subs_test.c +++ b/test/unit/subs_test.c @@ -88,6 +88,9 @@ int main(int argc, char *argv[]) CU_pSuite test_suite = NULL; unsigned int fails; + UNUSED(argc); + UNUSED(argv); + if(CU_initialize_registry() != CUE_SUCCESS){ printf("Error initializing CUnit registry.\n"); return 1; diff --git a/test/unit/test.c b/test/unit/test.c index 97258c49bf..c59a74610c 100644 --- a/test/unit/test.c +++ b/test/unit/test.c @@ -18,6 +18,9 @@ int main(int argc, char *argv[]) { unsigned int fails; + UNUSED(argc); + UNUSED(argv); + if(CU_initialize_registry() != CUE_SUCCESS){ printf("Error initializing CUnit registry.\n"); return 1;
0
d6958471ada84827d70cd67f62a7d0d6e4cb4a27
https://github.com/redis-store/redis-store/commit/d6958471ada84827d70cd67f62a7d0d6e4cb4a27
v1.8.0: Support Redis Cluster
diff --git a/lib/redis/store/version.rb b/lib/redis/store/version.rb index d9b47c6..397c7c7 100644 --- a/lib/redis/store/version.rb +++ b/lib/redis/store/version.rb @@ -1,5 +1,5 @@ class Redis class Store < self - VERSION = '1.7.0' + VERSION = '1.8.0' end end
0
6d2c3aaa111c55dc991cec779a7243c0a2d4de91
https://github.com/GNUAspell/aspell/commit/6d2c3aaa111c55dc991cec779a7243c0a2d4de91
Increment so version for release.
diff --git a/Makefile.am b/Makefile.am index 7b6fa46..ba66df5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -109,10 +109,10 @@ libaspell_la_LIBADD = $(LTLIBINTL) $(PTHREAD_LIB) ## for more into ## if INCREMENTED_SONAME -libaspell_la_LDFLAGS = -version-info 19:0:3 -no-undefined +libaspell_la_LDFLAGS = -version-info 19:1:3 -no-undefined else ## Use C-1:R:A -libaspell_la_LDFLAGS = -version-info 18:0:3 -no-undefined +libaspell_la_LDFLAGS = -version-info 18:1:3 -no-undefined endif if PSPELL_COMPATIBILITY
0
afcec249b82cad60978e8ecb3926822d3f51b25a
https://github.com/primefaces/primefaces/commit/afcec249b82cad60978e8ecb3926822d3f51b25a
Fix #1194: XSS in DialogFramework.
diff --git a/src/main/java/org/primefaces/application/DialogNavigationHandler.java b/src/main/java/org/primefaces/application/DialogNavigationHandler.java index b694a0c484..ac72873919 100644 --- a/src/main/java/org/primefaces/application/DialogNavigationHandler.java +++ b/src/main/java/org/primefaces/application/DialogNavigationHandler.java @@ -84,7 +84,7 @@ public void handleNavigation(FacesContext context, String fromAction, String out sb.append(optionName).append(":"); if (optionValue instanceof String) { - sb.append("'").append(optionValue).append("'"); + sb.append("'").append(ComponentUtils.escapeEcmaScriptText((String) optionValue)).append("'"); } else { sb.append(optionValue);
1
d3f87aa3e250c9a42deda44e14d600f60328768e
https://github.com/OPCFoundation/UA-.NET-Legacy/commit/d3f87aa3e250c9a42deda44e14d600f60328768e
Skip server nonce validation in ClientSession if the nonce is not used for encryption.
diff --git a/SampleApplications/SampleLibraries/Client/Session.cs b/SampleApplications/SampleLibraries/Client/Session.cs index 2b36058..7f63331 100644 --- a/SampleApplications/SampleLibraries/Client/Session.cs +++ b/SampleApplications/SampleLibraries/Client/Session.cs @@ -3318,21 +3318,19 @@ protected virtual void ValidateSoftwareCertificates(List<SoftwareCertificate> so /// </summary> private void ValidateServerNonce(IUserIdentity identity, byte[] serverNonce, string securityPolicyUri) { + // skip validation if server nonce is not used for encryption. + if (String.IsNullOrEmpty(securityPolicyUri) || securityPolicyUri == SecurityPolicies.None) + { + return; + } + if (identity != null && identity.TokenType != UserTokenType.Anonymous) { // the server nonce should be validated if the token includes a secret. - if (!Utils.Nonce.ValidateNonce(serverNonce, MessageSecurityMode.SignAndEncrypt, securityPolicyUri)) + if (!Utils.Nonce.ValidateNonce(serverNonce, MessageSecurityMode.SignAndEncrypt, m_configuration.SecurityConfiguration.NonceLength)) { throw ServiceResultException.Create(StatusCodes.BadNonceInvalid, "Server nonce is not the correct length or not random enough."); } - - // token encryption is mandatory over a channel without security if it includes a secret. - if (m_endpoint != null && m_endpoint.Description != null && - m_endpoint.Description.SecurityPolicyUri == SecurityPolicies.None && - securityPolicyUri == SecurityPolicies.None) - { - throw ServiceResultException.Create(StatusCodes.BadSecurityModeInsufficient, "User identity cannot be sent over the current secure channel without encryption."); - } } } diff --git a/Stack/Core/Types/Utils/Utils.cs b/Stack/Core/Types/Utils/Utils.cs index 1e6e35c..06274c3 100644 --- a/Stack/Core/Types/Utils/Utils.cs +++ b/Stack/Core/Types/Utils/Utils.cs @@ -2363,6 +2363,14 @@ public static int GetNonceLength(string securityPolicyUri) /// Validates the nonce for a message security mode and security policy. /// </summary> public static bool ValidateNonce(byte[] nonce, MessageSecurityMode securityMode, string securityPolicyUri) + { + return ValidateNonce(nonce, securityMode, GetNonceLength(securityPolicyUri)); + } + + /// <summary> + /// Validates the nonce for a message security mode and a minimum length. + /// </summary> + public static bool ValidateNonce(byte[] nonce, MessageSecurityMode securityMode, int minNonceLength) { // no nonce needed for no security. if (securityMode == MessageSecurityMode.None) @@ -2371,7 +2379,7 @@ public static bool ValidateNonce(byte[] nonce, MessageSecurityMode securityMode, } // check the length. - if (nonce == null || nonce.Length < GetNonceLength(securityPolicyUri)) + if (nonce == null || nonce.Length < minNonceLength) { return false; }
0
9710f9b6fd75955e09de81a228e16f63a1e5a2a7
https://github.com/NationalSecurityAgency/ghidra/commit/9710f9b6fd75955e09de81a228e16f63a1e5a2a7
GP-0 fix DWARF data type import and flex array definitions
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf4/next/DWARFDataTypeImporter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf4/next/DWARFDataTypeImporter.java index 724f5083c1..b7d726f0be 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf4/next/DWARFDataTypeImporter.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf4/next/DWARFDataTypeImporter.java @@ -16,20 +16,56 @@ package ghidra.app.util.bin.format.dwarf4.next; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import ghidra.app.plugin.core.datamgr.util.DataTypeUtils; import ghidra.app.util.DataTypeNamingUtil; -import ghidra.app.util.bin.format.dwarf4.*; -import ghidra.app.util.bin.format.dwarf4.encoding.*; +import ghidra.app.util.bin.format.dwarf4.DIEAggregate; +import ghidra.app.util.bin.format.dwarf4.DWARFUtil; +import ghidra.app.util.bin.format.dwarf4.DebugInfoEntry; +import ghidra.app.util.bin.format.dwarf4.encoding.DWARFAttribute; +import ghidra.app.util.bin.format.dwarf4.encoding.DWARFEndianity; +import ghidra.app.util.bin.format.dwarf4.encoding.DWARFTag; import ghidra.app.util.bin.format.dwarf4.expression.DWARFExpressionException; import ghidra.program.database.DatabaseObject; import ghidra.program.database.data.DataTypeUtilities; -import ghidra.program.model.data.*; +import ghidra.program.model.data.Array; +import ghidra.program.model.data.ArrayDataType; +import ghidra.program.model.data.BitFieldDataType; +import ghidra.program.model.data.CategoryPath; +import ghidra.program.model.data.DataType; +import ghidra.program.model.data.DataTypeComponent; +import ghidra.program.model.data.DataTypeConflictHandler; +import ghidra.program.model.data.DataTypeImpl; +import ghidra.program.model.data.DataTypeManager; +import ghidra.program.model.data.DefaultDataType; +import ghidra.program.model.data.Dynamic; import ghidra.program.model.data.Enum; +import ghidra.program.model.data.EnumDataType; +import ghidra.program.model.data.FactoryDataType; +import ghidra.program.model.data.FunctionDefinitionDataType; +import ghidra.program.model.data.GenericCallingConvention; +import ghidra.program.model.data.InvalidDataTypeException; +import ghidra.program.model.data.ParameterDefinition; +import ghidra.program.model.data.ParameterDefinitionImpl; +import ghidra.program.model.data.Pointer; +import ghidra.program.model.data.PointerDataType; +import ghidra.program.model.data.Structure; +import ghidra.program.model.data.StructureDataType; +import ghidra.program.model.data.TypeDef; +import ghidra.program.model.data.TypedefDataType; +import ghidra.program.model.data.Undefined; +import ghidra.program.model.data.UnionDataType; import ghidra.util.InvalidNameException; import ghidra.util.Msg; import ghidra.util.exception.DuplicateNameException; @@ -141,7 +177,13 @@ public DWARFDataType getDataType(DIEAggregate diea, DWARFDataType defaultValue) return result; } DataType alreadyImportedDT = dwarfDTM.getDataType(diea.getOffset(), null); - if (alreadyImportedDT != null) { + if (alreadyImportedDT != null && + !(alreadyImportedDT instanceof Array && + ((Array) alreadyImportedDT).getNumElements() == 1)) { + // HACK: don't re-use previously imported single-element + // Ghidra array datatype because they may have actually been an empty array + // definition we need the special meta-data flag DWARFDataType.isEmptyArrayType + // which is only available in a freshly created DWARFDataType. return new DWARFDataType(alreadyImportedDT, null, diea.getOffset()); }
0
91d5822d68e43760f967b45751279d12314b7a10
https://github.com/ansible/ansible-modules-extras/commit/91d5822d68e43760f967b45751279d12314b7a10
Add oVirt ovirt_permissions and ovirt_permissions_facts modules (#3160)
diff --git a/cloud/ovirt/ovirt_permissions.py b/cloud/ovirt/ovirt_permissions.py new file mode 100644 index 00000000000..11a3182ad23 --- /dev/null +++ b/cloud/ovirt/ovirt_permissions.py @@ -0,0 +1,287 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +try: + import ovirtsdk4.types as otypes +except ImportError: + pass + +import traceback + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.ovirt import ( + BaseModule, + check_sdk, + create_connection, + equal, + follow_link, + get_link_name, + ovirt_full_argument_spec, + search_by_attributes, + search_by_name, +) + + +DOCUMENTATION = ''' +--- +module: ovirt_permissions +short_description: "Module to manage permissions of users/groups in oVirt" +version_added: "2.3" +author: "Ondra Machacek (@machacekondra)" +description: + - "Module to manage permissions of users/groups in oVirt" +options: + role: + description: + - "Name of the the role to be assigned to user/group on specific object." + default: UserRole + state: + description: + - "Should the permission be present/absent." + choices: ['present', 'absent'] + default: present + object_id: + description: + - "ID of the object where the permissions should be managed." + object_name: + description: + - "Name of the object where the permissions should be managed." + object_type: + description: + - "The object where the permissions should be managed." + default: 'virtual_machine' + choices: [ + 'data_center', + 'cluster', + 'host', + 'storage_domain', + 'network', + 'disk', + 'vm', + 'vm_pool', + 'template', + ] + user_name: + description: + - "Username of the the user to manage. In most LDAPs it's I(uid) of the user, but in Active Directory you must specify I(UPN) of the user." + group_name: + description: + - "Name of the the group to manage." + authz_name: + description: + - "Authorization provider of the user/group. In previous versions of oVirt known as domain." + required: true + aliases: ['domain'] + namespace: + description: + - "Namespace of the authorization provider, where user/group resides." + required: false +extends_documentation_fragment: ovirt +''' + +EXAMPLES = ''' +# Examples don't contain auth parameter for simplicity, +# look at ovirt_auth module to see how to reuse authentication: + +# Add user user1 from authorization provider example.com-authz +- ovirt_permissions: + user_name: user1 + authz_name: example.com-authz + object_type: vm + object_name: myvm + role: UserVmManager + +# Remove permission from user +- ovirt_permissions: + state: absent + user_name: user1 + authz_name: example.com-authz + object_type: cluster + object_name: mycluster + role: ClusterAdmin +''' + +RETURN = ''' +id: + description: ID of the permission which is managed + returned: On success if permission is found. + type: str + sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c +permission: + description: "Dictionary of all the permission attributes. Permission attributes can be found on your oVirt instance + at following url: https://ovirt.example.com/ovirt-engine/api/model#types/permission." + returned: On success if permission is found. +''' + + +def _objects_service(connection, object_type): + return getattr( + connection.system_service(), + '%ss_service' % object_type, + None, + )() + + +def _object_service(connection, module): + object_type = module.params['object_type'] + objects_service = _objects_service(connection, object_type) + + object_id = module.params['object_id'] + if object_id is None: + sdk_object = search_by_name(objects_service, module.params['object_name']) + if sdk_object is None: + raise Exception( + "'%s' object '%s' was not found." % ( + module.params['object_type'], + module.params['object_name'] + ) + ) + object_id = sdk_object.id + + return objects_service.service(object_id) + + +def _permission(module, permissions_service, connection): + for permission in permissions_service.list(): + user = follow_link(connection, permission.user) + if ( + equal(module.params['user_name'], user.principal if user else None) and + equal(module.params['group_name'], get_link_name(connection, permission.group)) and + equal(module.params['role'], get_link_name(connection, permission.role)) + ): + return permission + + +class PermissionsModule(BaseModule): + + def _user(self): + user = search_by_attributes( + self._connection.system_service().users_service(), + usrname="{name}@{authz_name}".format( + name=self._module.params['user_name'], + authz_name=self._module.params['authz_name'], + ), + ) + if user is None: + raise Exception("User '%s' was not found." % self._module.params['user_name']) + return user + + def _group(self): + groups = self._connection.system_service().groups_service().list( + search="name={name}".format( + name=self._module.params['group_name'], + ) + ) + + # If found more groups, filter them by namespace and authz name: + # (filtering here, as oVirt backend doesn't support it) + if len(groups) > 1: + groups = [ + g for g in groups if ( + equal(self._module.params['namespace'], g.namespace) and + equal(self._module.params['authz_name'], g.domain.name) + ) + ] + if not groups: + raise Exception("Group '%s' was not found." % self._module.params['group_name']) + return groups[0] + + def build_entity(self): + entity = self._group() if self._module.params['group_name'] else self._user() + + return otypes.Permission( + user=otypes.User( + id=entity.id + ) if self._module.params['user_name'] else None, + group=otypes.Group( + id=entity.id + ) if self._module.params['group_name'] else None, + role=otypes.Role( + name=self._module.params['role'] + ), + ) + + +def main(): + argument_spec = ovirt_full_argument_spec( + state=dict( + choices=['present', 'absent'], + default='present', + ), + role=dict(default='UserRole'), + object_type=dict( + default='virtual_machine', + choices=[ + 'data_center', + 'cluster', + 'host', + 'storage_domain', + 'network', + 'disk', + 'vm', + 'vm_pool', + 'template', + ] + ), + authz_name=dict(required=True, aliases=['domain']), + object_id=dict(default=None), + object_name=dict(default=None), + user_name=dict(rdefault=None), + group_name=dict(default=None), + namespace=dict(default=None), + ) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + check_sdk(module) + + if module.params['object_name'] is None and module.params['object_id'] is None: + module.fail_json(msg='"object_name" or "object_id" is required') + + if module.params['user_name'] is None and module.params['group_name'] is None: + module.fail_json(msg='"user_name" or "group_name" is required') + + try: + connection = create_connection(module.params.pop('auth')) + permissions_service = _object_service(connection, module).permissions_service() + permissions_module = PermissionsModule( + connection=connection, + module=module, + service=permissions_service, + ) + + permission = _permission(module, permissions_service, connection) + state = module.params['state'] + if state == 'present': + ret = permissions_module.create(entity=permission) + elif state == 'absent': + ret = permissions_module.remove(entity=permission) + + module.exit_json(**ret) + except Exception as e: + module.fail_json(msg=str(e), exception=traceback.format_exc()) + finally: + connection.close(logout=False) + + +if __name__ == "__main__": + main() diff --git a/cloud/ovirt/ovirt_permissions_facts.py b/cloud/ovirt/ovirt_permissions_facts.py new file mode 100644 index 00000000000..2c1b4fb5c01 --- /dev/null +++ b/cloud/ovirt/ovirt_permissions_facts.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +import traceback + +try: + import ovirtsdk4 as sdk +except ImportError: + pass + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.ovirt import ( + check_sdk, + create_connection, + get_link_name, + ovirt_full_argument_spec, + search_by_name, +) + + +DOCUMENTATION = ''' +--- +module: ovirt_permissions_facts +short_description: Retrieve facts about one or more oVirt permissions +author: "Ondra Machacek (@machacekondra)" +version_added: "2.3" +description: + - "Retrieve facts about one or more oVirt permissions." +notes: + - "This module creates a new top-level C(ovirt_permissions) fact, which + contains a list of permissions." +options: + user_name: + description: + - "Username of the the user to manage. In most LDAPs it's I(uid) of the user, but in Active Directory you must specify I(UPN) of the user." + group_name: + description: + - "Name of the the group to manage." + authz_name: + description: + - "Authorization provider of the user/group. In previous versions of oVirt known as domain." + required: true + aliases: ['domain'] + namespace: + description: + - "Namespace of the authorization provider, where user/group resides." + required: false +extends_documentation_fragment: ovirt +''' + +EXAMPLES = ''' +# Examples don't contain auth parameter for simplicity, +# look at ovirt_auth module to see how to reuse authentication: + +# Gather facts about all permissions of user with username C(john): +- ovirt_permissions_facts: + user_name: john + authz_name: example.com-authz +- debug: + var: ovirt_permissions +''' + +RETURN = ''' +ovirt_permissions: + description: "List of dictionaries describing the permissions. Permission attribues are mapped to dictionary keys, + all permissions attributes can be found at following url: https://ovirt.example.com/ovirt-engine/api/model#types/permission." + returned: On success. + type: list +''' + + +def _permissions_service(connection, module): + if module.params['user_name']: + service = connection.system_service().users_service() + entity = search_by_name(service, module.params['user_name']) + else: + service = connection.system_service().groups_service() + entity = search_by_name(service, module.params['group_name']) + + if entity is None: + raise Exception("User/Group wasn't found.") + + return service.service(entity.id).permissions_service() + + +def main(): + argument_spec = ovirt_full_argument_spec( + authz_name=dict(required=True, aliases=['domain']), + user_name=dict(rdefault=None), + group_name=dict(default=None), + namespace=dict(default=None), + ) + module = AnsibleModule(argument_spec) + check_sdk(module) + + try: + connection = create_connection(module.params.pop('auth')) + permissions_service = _permissions_service(connection, module) + permissions = [] + for p in permissions_service.list(): + newperm = dict() + for key, value in p.__dict__.items(): + if value and isinstance(value, sdk.Struct): + newperm[key[1:]] = get_link_name(connection, value) + permissions.append(newperm) + + module.exit_json( + changed=False, + ansible_facts=dict(ovirt_permissions=permissions), + ) + except Exception as e: + module.fail_json(msg=str(e), exception=traceback.format_exc()) + finally: + connection.close(logout=False) + + +if __name__ == '__main__': + main()
0
afa0bc5fe9a4f635e347def7f5e4742ba87f79f7
https://github.com/adaltas/node-csv-parse/commit/afa0bc5fe9a4f635e347def7f5e4742ba87f79f7
refactor: rename state wasRecordDelimiter to wasRowDelimiter
diff --git a/lib/browser/index.js b/lib/browser/index.js index 2c1594d..2c427bc 100644 --- a/lib/browser/index.js +++ b/lib/browser/index.js @@ -6995,7 +6995,7 @@ class Parser extends Transform { recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false } } // Implementation of `Transform._transform` @@ -7068,12 +7068,12 @@ class Parser extends Transform { if(this.__needMoreData(pos, bufLen, end)){ break } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ this.state.info = Object.assign({}, this.info) } - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } if(to_line !== -1 && this.info.lines > to_line){ this.state.stop = true @@ -7091,8 +7091,8 @@ class Parser extends Transform { if(raw === true){ rawBuffer.append(chr) } - if((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false ){ - this.state.wasRecordDelimiter = true + if((chr === cr || chr === nl) && this.state.wasRowDelimiter === false ){ + this.state.wasRowDelimiter = true } // Previous char was a valid escape char // treat the current char as a regular char @@ -7187,7 +7187,7 @@ class Parser extends Transform { continue } // Activate records emition if above from_line - if(this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1: 0 ) >= from_line){ + if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0 ) >= from_line){ this.state.enabled = true this.__resetField() this.__resetRecord() @@ -7273,7 +7273,7 @@ class Parser extends Transform { if(errField !== undefined) return errField const errRecord = this.__onRecord() if(errRecord !== undefined) return errRecord - }else if(this.state.wasRecordDelimiter === true){ + }else if(this.state.wasRowDelimiter === true){ this.info.empty_lines++ }else if(this.state.commenting === true){ this.info.comment_lines++ @@ -7282,9 +7282,9 @@ class Parser extends Transform { }else{ this.state.previousBuf = buf.slice(pos) } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } } __onRecord(){ diff --git a/lib/browser/sync.js b/lib/browser/sync.js index 64adb60..c589a23 100644 --- a/lib/browser/sync.js +++ b/lib/browser/sync.js @@ -6995,7 +6995,7 @@ class Parser extends Transform { recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false } } // Implementation of `Transform._transform` @@ -7068,12 +7068,12 @@ class Parser extends Transform { if(this.__needMoreData(pos, bufLen, end)){ break } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ this.state.info = Object.assign({}, this.info) } - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } if(to_line !== -1 && this.info.lines > to_line){ this.state.stop = true @@ -7091,8 +7091,8 @@ class Parser extends Transform { if(raw === true){ rawBuffer.append(chr) } - if((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false ){ - this.state.wasRecordDelimiter = true + if((chr === cr || chr === nl) && this.state.wasRowDelimiter === false ){ + this.state.wasRowDelimiter = true } // Previous char was a valid escape char // treat the current char as a regular char @@ -7187,7 +7187,7 @@ class Parser extends Transform { continue } // Activate records emition if above from_line - if(this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1: 0 ) >= from_line){ + if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0 ) >= from_line){ this.state.enabled = true this.__resetField() this.__resetRecord() @@ -7273,7 +7273,7 @@ class Parser extends Transform { if(errField !== undefined) return errField const errRecord = this.__onRecord() if(errRecord !== undefined) return errRecord - }else if(this.state.wasRecordDelimiter === true){ + }else if(this.state.wasRowDelimiter === true){ this.info.empty_lines++ }else if(this.state.commenting === true){ this.info.comment_lines++ @@ -7282,9 +7282,9 @@ class Parser extends Transform { }else{ this.state.previousBuf = buf.slice(pos) } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } } __onRecord(){ diff --git a/lib/es5/index.js b/lib/es5/index.js index f7b2768..855aed0 100644 --- a/lib/es5/index.js +++ b/lib/es5/index.js @@ -531,7 +531,7 @@ var Parser = /*#__PURE__*/function (_Transform) { }))), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false }; } // Implementation of `Transform._transform` @@ -642,14 +642,14 @@ var Parser = /*#__PURE__*/function (_Transform) { break; } - if (this.state.wasRecordDelimiter === true) { + if (this.state.wasRowDelimiter === true) { this.info.lines++; if (info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false) { this.state.info = Object.assign({}, this.info); } - this.state.wasRecordDelimiter = false; + this.state.wasRowDelimiter = false; } if (to_line !== -1 && this.info.lines > to_line) { @@ -673,8 +673,8 @@ var Parser = /*#__PURE__*/function (_Transform) { rawBuffer.append(chr); } - if ((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false) { - this.state.wasRecordDelimiter = true; + if ((chr === cr || chr === nl) && this.state.wasRowDelimiter === false) { + this.state.wasRowDelimiter = true; } // Previous char was a valid escape char // treat the current char as a regular char @@ -767,7 +767,7 @@ var Parser = /*#__PURE__*/function (_Transform) { } // Activate records emition if above from_line - if (this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1 : 0) >= from_line) { + if (this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1 : 0) >= from_line) { this.state.enabled = true; this.__resetField(); @@ -858,7 +858,7 @@ var Parser = /*#__PURE__*/function (_Transform) { var _errRecord = this.__onRecord(); if (_errRecord !== undefined) return _errRecord; - } else if (this.state.wasRecordDelimiter === true) { + } else if (this.state.wasRowDelimiter === true) { this.info.empty_lines++; } else if (this.state.commenting === true) { this.info.comment_lines++; @@ -868,9 +868,9 @@ var Parser = /*#__PURE__*/function (_Transform) { this.state.previousBuf = buf.slice(pos); } - if (this.state.wasRecordDelimiter === true) { + if (this.state.wasRowDelimiter === true) { this.info.lines++; - this.state.wasRecordDelimiter = false; + this.state.wasRowDelimiter = false; } } }, { diff --git a/lib/index.js b/lib/index.js index 6b3577e..ab248d7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -456,7 +456,7 @@ class Parser extends Transform { recordDelimiterMaxLength: options.record_delimiter.length === 0 ? 2 : Math.max(...options.record_delimiter.map( (v) => v.length)), trimChars: [Buffer.from(' ', options.encoding)[0], Buffer.from('\t', options.encoding)[0]], wasQuoting: false, - wasRecordDelimiter: false + wasRowDelimiter: false } } // Implementation of `Transform._transform` @@ -529,12 +529,12 @@ class Parser extends Transform { if(this.__needMoreData(pos, bufLen, end)){ break } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ if(info === true && this.state.record.length === 0 && this.state.field.length === 0 && this.state.wasQuoting === false){ this.state.info = Object.assign({}, this.info) } - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } if(to_line !== -1 && this.info.lines > to_line){ this.state.stop = true @@ -552,8 +552,8 @@ class Parser extends Transform { if(raw === true){ rawBuffer.append(chr) } - if((chr === cr || chr === nl) && this.state.wasRecordDelimiter === false ){ - this.state.wasRecordDelimiter = true + if((chr === cr || chr === nl) && this.state.wasRowDelimiter === false ){ + this.state.wasRowDelimiter = true } // Previous char was a valid escape char // treat the current char as a regular char @@ -648,7 +648,7 @@ class Parser extends Transform { continue } // Activate records emition if above from_line - if(this.state.enabled === false && this.info.lines + (this.state.wasRecordDelimiter === true ? 1: 0 ) >= from_line){ + if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0 ) >= from_line){ this.state.enabled = true this.__resetField() this.__resetRecord() @@ -734,7 +734,7 @@ class Parser extends Transform { if(errField !== undefined) return errField const errRecord = this.__onRecord() if(errRecord !== undefined) return errRecord - }else if(this.state.wasRecordDelimiter === true){ + }else if(this.state.wasRowDelimiter === true){ this.info.empty_lines++ }else if(this.state.commenting === true){ this.info.comment_lines++ @@ -743,9 +743,9 @@ class Parser extends Transform { }else{ this.state.previousBuf = buf.slice(pos) } - if(this.state.wasRecordDelimiter === true){ + if(this.state.wasRowDelimiter === true){ this.info.lines++ - this.state.wasRecordDelimiter = false + this.state.wasRowDelimiter = false } } __onRecord(){ diff --git a/test/option.from_line.coffee b/test/option.from_line.coffee index c3cf883..aab06d7 100644 --- a/test/option.from_line.coffee +++ b/test/option.from_line.coffee @@ -80,7 +80,7 @@ describe 'Option `from_line`', -> ] unless err next err - it 'not influenced by record delimiters', (next) -> + it 'not influenced by `record_delimiter` option', (next) -> parse """ a,b,c:1,2, 3:d,e,f:4,5,
0
58ed8655136ff2fe5ff7796859bf6a399c76c678
https://github.com/redmine/redmine/commit/58ed8655136ff2fe5ff7796859bf6a399c76c678
mercurial: separate command options and positional arguments with "--" (#27516) We don't have much problems here thanks to hgtarget(path) and CGI.escape(), which prepends a repository path and encodes "=" character respectively, but it's better to not rely on the side effect of these functions. Contributed by Yuya Nishihara. git-svn-id: http://svn.redmine.org/redmine/trunk@17061 e93f8b46-1217-0410-a6f0-8f06a7374b81
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index 2c712135664..0e7f766d472 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -141,7 +141,7 @@ def summary def entries(path=nil, identifier=nil, options={}) p1 = scm_iconv(@path_encoding, 'UTF-8', path) manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)), - CGI.escape(without_leading_slash(p1.to_s))) do |io| + '--', CGI.escape(without_leading_slash(p1.to_s))) do |io| output = io.read.force_encoding('UTF-8') begin parse_xml(output)['rhmanifest']['repository']['manifest'] @@ -184,7 +184,7 @@ def each_revision(path=nil, identifier_from=nil, identifier_to=nil, options={}) hg_args = ['log', '--debug', '-C', '--style', self.class.template_path] hg_args << '-r' << "#{hgrev(identifier_from)}:#{hgrev(identifier_to)}" hg_args << '--limit' << options[:limit] if options[:limit] - hg_args << hgtarget(path) unless path.blank? + hg_args << '--' << hgtarget(path) unless path.blank? log = hg(*hg_args) do |io| output = io.read.force_encoding('UTF-8') begin @@ -240,7 +240,7 @@ def diff(path, identifier_from, identifier_to=nil) end unless path.blank? p = scm_iconv(@path_encoding, 'UTF-8', path) - hg_args << CGI.escape(hgtarget(p)) + hg_args << '--' << CGI.escape(hgtarget(p)) end diff = [] hg *hg_args do |io| @@ -255,7 +255,7 @@ def diff(path, identifier_from, identifier_to=nil) def cat(path, identifier=nil) p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path)) - hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io| + hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io| io.binmode io.read end @@ -266,7 +266,7 @@ def cat(path, identifier=nil) def annotate(path, identifier=nil) p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path)) blame = Annotate.new - hg 'rhannotate', '-ncu', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io| + hg 'rhannotate', '-ncu', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io| io.each_line do |line| line.force_encoding('ASCII-8BIT') next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
1
38284f422126c0d0c97cf66c7a9f47e8cef8cb46
https://github.com/wernerd/ZRTPCPP/commit/38284f422126c0d0c97cf66c7a9f47e8cef8cb46
Merge branch 'develop'
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ede370..a4d96e6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,10 @@ cmake_minimum_required(VERSION 2.6) PROJECT(libzrtpcpp) SET(CPACK_PACKAGE_VERSION_MAJOR 4) -SET(CPACK_PACKAGE_VERSION_MINOR 5) +SET(CPACK_PACKAGE_VERSION_MINOR 6) SET(CPACK_PACKAGE_VERSION_PATCH 0) -set (VERSION 4.5.0) +set (VERSION 4.6.0) set (SOVERSION 4) # Define supported command line parameters. diff --git a/NEWS b/NEWS.md similarity index 79% rename from NEWS rename to NEWS.md index fd904ae..623312a 100755 --- a/NEWS +++ b/NEWS.md @@ -1,4 +1,14 @@ -== GNU ZRTP 4.5.0 == +## GNU ZRTP 4.6.0 ## + +Only a small add-on to the code to implement handling of the +disclosure flag. See RFC6189, chapter 11 for more details +about the disclosure flag. + +Because the API changed, thus it's necessary to recompile +applications that use the new library version. + + +## GNU ZRTP 4.5.0 ## Added a new SAS algorithm 'B32E' that uses 32 Unicode Emoji code points instead of 32 ASCII characters. Application that @@ -7,14 +17,15 @@ display nice Emojis instead of 'boring' ASCII letters and digits. Some technical details: -- the 32 selected emojis are easily distinguishable, known to + +* the 32 selected emojis are easily distinguishable, known to everyone, not offending etc, and use standard Unicode code points -- select colored emojis that look good on white and on black +* select colored emojis that look good on white and on black backgrounds (most emojis look good on white only) -- select emojis that are available on iOS, Android, Mac OS X +* select emojis that are available on iOS, Android, Mac OS X (Windows not checked) -- the resulting SAS string is UTF-8 encoded, suitable for most +* the resulting SAS string is UTF-8 encoded, suitable for most platforms except Java. To use the codes for Java the application needs to translate the @@ -26,10 +37,13 @@ To support the UTF-8 / UTF-16 conversion the common directory contains conversion functions that I extracted from ICU C/C++ library source. +Because the API changed, thus it's necessary to recompile +applications that use the new library version. + -== GNU ZRTP 4.4.0 == +## GNU ZRTP 4.4.0 ## -Changes the handling of HMAC and Hash contexts to avoild tool +Changes the handling of HMAC and Hash contexts to avoid too many malloc/free calls and thus memory pointer problems. Enhance the handling an check the nonce when using multi-stream @@ -41,7 +55,11 @@ checks. Some bug fixing as well. -== GNU ZRTP 4.3.1 == +Because the API changed, thus it's necessary to recompile +applications that use the new library version. + + +## GNU ZRTP 4.3.1 ## This is a bugfix release. It fixes several compiler issues in iOS8 Clang, Mircosoft C++ compiler (VS 2012) etc. @@ -54,7 +72,7 @@ software that deals with secure keys :-) . The fix removes this possible vulnerability. -== GNU ZRTP 4.3.0 == +## GNU ZRTP 4.3.0 ## This version adds some new API that provide to set retry timer values and to get some retry counters. @@ -77,39 +95,39 @@ Because we have a new set of functions the API changed, thus it's necessary to recompile applications that use the new library version. -== GNU ZRTP 4.2.4 == +## GNU ZRTP 4.2.4 ## Only small changes to enable Android X86 (see clients/tivi/android) as an example. Rename functions aes_init() to aes_init_zrtp() to avoid names clashes -with other libreries that may include own AES modules. +with other libraries that may include own AES modules. -== GNU ZRTP 4.2.3 == +## GNU ZRTP 4.2.3 ## The optional SAS relay feature (refer to RFC6189, chapter 7.3) is not longer compiled by default. If your project needs this support then modify the CMakeLists.txt file and uncomment a 'add_definition' -statments. See comment in the CMakelists.txt file. +statements. See comment in the CMakelists.txt file. The reasons to disable this optional feature in the default build: it's rarely used and some concerns about misusing this feature. -== GNU ZRTP 4.2.2 == +## GNU ZRTP 4.2.2 ## A small enhancement in SRTP handling to provide a longer bit-shift -register with 128 bits. The replay now check accepts packets which -are up to 127 sequence number behing the current packet. The upper +register with 128 bits. The replay check now accepts packets which +are up to 127 sequence number behind the current packet. The upper layer (codecs) gets more packets on slower/bad networks that we may see on mobile 3G/4G connections. If the codecs do not remove silence then this may lead to some longer -audio replay, similar to sattelite communication. +audio replay, similar to satellite communication. -== GNU ZRTP 4.2.1 == +## GNU ZRTP 4.2.1 ## Bug fixes in the SRTP part that checks for replay and updates the ROC. @@ -122,7 +140,7 @@ Please check the inline documentation and the compiler warning how to use the return value of the function. -== GNU ZRTP 4.2.0 == +## GNU ZRTP 4.2.0 ## Implemented a new function to read the ZID file if the ZID file backend is SQlite3. This is not a security problem because the ZRTP cache was @@ -131,18 +149,18 @@ always public and readable, refer to RFC6189. SQL statement returns all ZID records, sorted by date, newest on top. The function can then step thru the DB cursor and read the records. -The version also include sevral fixes, usually compiler warnings, some +The version also include several fixes, usually compiler warnings, some small problems reported by 'cppcheck' analyser. Because we have a new set of functions the API changed, thus it's necessary to recompile applications that use the new library version. -== GNU ZRTP 4.1.2 == +## GNU ZRTP 4.1.2 ## Fix the library's name in libzrtpcpp.pc.make -== GNU ZRTP 4.1.1 == +## GNU ZRTP 4.1.1 ## Is a bug fix release that fixes some problems when building a standalone version of the library, i.e. with embedded crypto algorithms and not using @@ -151,7 +169,7 @@ on openSSL. Another fix was necessary for NetBSD thread handling. -== GNU ZRTP 4.1.0 == +## GNU ZRTP 4.1.0 ## Small enhancements when dealing with non-NIST algorithms. An application may set a ''algorithm selection policy'' to control the selection behaviour. In @@ -161,10 +179,10 @@ is a non-NIST ECC algorithm then the other selection functions prefer non-NIST HASH algorithms (Skein etc). -== GNU ZRTP 4.0.0 == +## GNU ZRTP 4.0.0 ## For this version I added some new algorithms for the DH key agreement -and the Skein Hash for ZRTP. Not further functional enhancments. +and the Skein Hash for ZRTP. Not further functional enhancements. Added a new (old) build parameter -DCORE_LIB that will build a ZRTP core library. This was available in V2.3 but I somehow lost this for 3.0 @@ -172,7 +190,7 @@ You may add other build parameters, such as SQLITE and CRYPTO_STANDALONE if you build the core library. -== GNU ZRTP 3.2.0 == +## GNU ZRTP 3.2.0 ## The main ZRTP modules contain fixes for three vulnerabilities found by Mark Dowd. Thus we advise application developers to use this version of the @@ -183,8 +201,8 @@ attack vectors. Some small other enhancements and cleanup, mainly inside client code. Some enhancements in cache handling and the handling of retained shared -secrets. This change was proposed by Phil, is a slight security enhacement and -is fully backward comaptible. +secrets. This change was proposed by Phil, is a slight security enhancement and +is fully backward compatible. Because of some API changes clients must be compiled and linked with the new library. @@ -192,7 +210,7 @@ library. For details please refer to the Git logs. -== GNU ZRTP 3.1.0 == +## GNU ZRTP 3.1.0 ## This version adds some new features and code that supports some other client and this accounts for the most changes inside this release. @@ -204,14 +222,15 @@ SDES support module. This module supports basic SDES only without the fancy stuff like many other SDES implementations. Thus it's pretty interoperable. Some other features are: -- add some android support for a client, may serve as template for others -- documentation and code cleanup + +* add some android support for a client, may serve as template for others +* documentation and code cleanup Because of some API changes clients must be compiled and linked with the new library. -== GNU ZRTP 3.0.0 == +## GNU ZRTP 3.0.0 ## This is a major enhancement and restructuring of the overall ZRTP distribution. This was necessary because more and more other clients use ZRTP @@ -219,11 +238,12 @@ and add their specific glue code. Also some clients are not prepared to use openSSL or other crypto libraries to their code and distributions. Here a summary of the changes -- a new directory layout to accomodate various clients -- add standalone crypto modules, for example for AES, to have a real + +* a new directory layout to accommodate various clients +* add standalone crypto modules, for example for AES, to have a real standalone ZRTP/SRTP library that does not require any other crypto library (optional via CMake configuration) -- Re-structure ZRTP cache and add SQlite3 as optional storage backend +* Re-structure ZRTP cache and add SQlite3 as optional storage backend The default settings for CMake build the normal ZRTP library that use openSSL as crypto backend, use the normal file based cache and include the GNU ccRTP @@ -234,17 +254,17 @@ Please refer to the top level CMakeFile.txt for options how to switch on the standalone crypto mode or the SQlite3 based cache storage. -== GNU ZRTP 2.3.0 == +## GNU ZRTP 2.3.0 ## Add a "paranoid" mode to ZRTP. If and applications switches to this mode then the ZRTP stack _always_ asks the user to confirm the SAS thus ZRTP behaves as if it does not have a cache to store the retained secrets. However, setting -the paranoid mode does not diable the cache, only the GUI behaviour. +the paranoid mode does not disable the cache, only the GUI behaviour. Enhance the CMake scripts to build a ZRTP library that does not contain GNU ccRTP modules and does not require ccRTP dependencies. -== GNU ZRTP 2.2.0 == +## GNU ZRTP 2.2.0 ## Add stubs, callbacks and other provisions to prepare the full implementation of the SAS signing feature, see RFC6189, section 7.2. This feature needs @@ -255,7 +275,7 @@ As usual smaller fixes, code clean up etc. Because of some API changes clients must be compiled and linked with the new library. -== GNU ZRTP 2.1.2 == +## GNU ZRTP 2.1.2 ## The main topic of this release was to add SRTCP support and some missing optional features of ZRTP. @@ -267,7 +287,7 @@ handling, refer to RFC6189 section 7.3ff. Because of some API changes clients must be compiled and linked with the new library. -== GNU ZRTP 2.0.0 == +## GNU ZRTP 2.0.0 ## Modify some files to use the new uCommon/commoncpp libraries instead of the GNU CC++ commoncpp2. This affects the ccRTP depended modules @@ -277,46 +297,49 @@ Updated to version 2.0.0 to be in synch with the ccRTP version number scheme. -== GNU ZRTP 1.6.0 == +## GNU ZRTP 1.6.0 ## This version implements the Elliptic Curve Diffie-Helman (ECDH) public-key algorithm. ZRTP also supports new algorithms which are defined as optional in the ZRTP RFC. These are: -- Skein Hash -- Skein MAC for authentication -- Twofish symmetric ciphers + +* Skein Hash +* Skein MAC for authentication +* Twofish symmetric ciphers Twofish ciphers and Skein MAC are supported by GNU ccRTP SRTP -implmentation as well. +implementation as well. -== GNU ZRTP 1.5.4 == +## GNU ZRTP 1.5.4 ## The changes in this release affect the ZRTP Configure mechanism only. -Some housekeeping stuff (desctructors) was added and the C Wrapper +Some housekeeping stuff (destructors) was added and the C Wrapper how support ZRTP configure as well. Because of some API changes (added destructors) clients must be compiled and linked with the new library. -== GNU ZRTP 1.5.2 == +## GNU ZRTP 1.5.2 ## Quite a lot of enhancements: -- a CMake based build process was added -- a C wrapper was added to enable C programs to use GNU ZRTP -- some fixes in the code (race condition solved) -- better support of multi-stream mode -- change the old cxx file extension to cpp, some build system don't + +* a CMake based build process was added +* a C wrapper was added to enable C programs to use GNU ZRTP +* some fixes in the code (race condition solved) +* better support of multi-stream mode +* change the old cxx file extension to cpp, some build system don't like the old cxx (Android NDK for example) -- and much more +* and much more Because of API changes clients must be compiled and linked with the new library. -== GNU ZRTP 1.5.0 == + +## GNU ZRTP 1.5.0 ## Adds a first version of a ZrtpConfigure class that provides applications to select which crypto and hash methods to use. @@ -324,53 +347,54 @@ to select which crypto and hash methods to use. Because of API changes clients must be compiled and linked with the new library. -== GNU ZRTP 1.4.5 == -Modify the Hello repeat timer handling to accomodate slow connections and/or +## GNU ZRTP 1.4.5 ## + +Modify the Hello repeat timer handling to accommodate slow connections and/or slow devices. Fix a problem when the other party sends only ZRTP packets at the beginning of a RTP session. -=== Interface changes in 1.4.5 === + +### Interface changes in 1.4.5 ### No external interfaces were changed, external API and ABI remain stable. Internal interface modifications only to implement Ping/PingAck handling. -== GNU ZRTP 1.4.4 == +## GNU ZRTP 1.4.4 ## Implement the Ping/PingAck packets and associated protocol extensions -as defined in [http://tools.ietf.org/html/draft-zimmermann-avt-zrtp-15]. +as defined in [RFC6189][]. -=== Interface changes in 1.4.4 === +### Interface changes in 1.4.4 ### No external interfaces were changed, external API and ABI remain stable. Internal interface modifications only to implement Ping/PingAck handling. -== GNU ZRTP 1.4.2 == +## GNU ZRTP 1.4.2 ## -Introduce the Key Derivation Function (KDF) as defined in -[http://tools.ietf.org/html/draft-zimmermann-avt-zrtp-12]. +Introduce the Key Derivation Function (KDF) as defined in [RFC6189][] The ZRTP protocol version was updated to 1.10. -=== Interface changes in 1.4.2 === +### Interface changes in 1.4.2 ### No interfaces were changed, API and ABI remain stable. -== GNU ZRTP 1.4.0 == +## GNU ZRTP 1.4.0 ## -This is the first release that is conformant to the ZRTP specification -that eventually will become a RFC. See: -[http://tools.ietf.org/html/draft-zimmermann-avt-zrtp-10] +This is the first release that conforms to the ZRTP specification +that eventually will become a [RFC6189][]. The ZRTP protocol version was updated to 1.00. +[RFC6189]: https://tools.ietf.org/html/rfc6189 -=== Interface changes in 1.4.0 === +### Interface changes in 1.4.0 ### The ZrtpQueue and ZRtp classes implement a new method to get the other party's ZID (ZRTP identifier). An application, for example a SIP or XMPP @@ -383,7 +407,7 @@ call after they confirmed a SAS once. Clients must be compiled and linked with the new library. -== GNU ZRTP 1.3.1 == +## GNU ZRTP 1.3.1 ## This is an update to version 1.3.0 and implements the ZRTP multi-stream mode handshake. The ZRTP protocl version was updated to 0.90 and @@ -396,7 +420,7 @@ recompile or rebuild of clients are necessary if they use 1.3.0. To checkout version 1.3.1 specify revision 494 (-r 494). -== GNU ZRTP 1.3.0 == +## GNU ZRTP 1.3.0 ## This version is and update to version 1.1.0 an implements the latest changes define in the ZRTP draft. The changes resulted in an update of the @@ -411,7 +435,7 @@ someone modified the first retained shared secret entry in the retained secret cache, for example disk/storage read error. This is a very unlikely situation. -=== Interface changes in Version 1.3.0 === +### Interface changes in Version 1.3.0 ### The Method ''setSipsSecret(...)'' is no longer available. ZRTP does not support this additional secret anymore. @@ -423,16 +447,15 @@ The method ''setSrtpsSecret(...)'' was renamed to ''setAuxSecret(...)'' to reflect the modification in the draft. -== GNU ZRTP 1.1.0 == +## GNU ZRTP 1.1.0 ## GNU ZRTP 1.1.0 implements the basic ZRTP as specificied in the document -''draft-zimmermann-avt-zrtp-06x''. You may access this at this URL: -[http://zfoneproject.com/zrtp_ietf.html] +''draft-zimmermann-avt-zrtp-06x''. You may access this document at[URL][] -This version of GNU ZRTP does not support the additiona featur of ZRTP -such as Multi-stream mode, Pre-shared mode, PBX enrollement, and SAS +This version of GNU ZRTP does not support the additional featurs of ZRTP +such as Multi-stream mode, Pre-shared mode, PBX enrollment, and SAS Signature. However, to keep the external interface as stable as -possible I already implmented stubs for the additional features. Some +possible I already implemented stubs for the additional features. Some later versions may have these features implemented, depending if they are required by the community. @@ -440,7 +463,9 @@ The current version of GNU ZRTP is compatible and was tested to work with the latest Zfone beta (dated April, 2nd) (see Zfone project site). -=== Interface changes == +[URL]: http://zfoneproject.com/zrtp_ietf.html + +### Interface changes ### The ''SymmetricZRTPSession'' implements some new methods to control ZRTP and its new features. An application usually uses only a few @@ -471,7 +496,7 @@ application's point of view ZRTP always calls showSAS and provides the verification information explicitly. -* The siganture of the following user callback methods was changed: +* The signature of the following user callback methods was changed: showMessage(GnuZrtpCodes::MessageSeverity sev, int32_t subCode) @@ -485,12 +510,12 @@ application's point of view strings. Delegating string handling and formating to the application simplifies internationalization etc. -Plaese note: some new callback methods and ''SymmetricZRTPSession'' -methods are only stubs in the currect version. The real implementation +Please note: some new callback methods and ''SymmetricZRTPSession'' +methods are only stubs in the current version. The real implementation (filling the stubs with real code) will be done some time later (see above about unsupported features). -=== Header files === +### Header files ### The new version greatly reduces the number of header files installed in the include directory. In the new version I decoupled the internal @@ -499,7 +524,7 @@ interfaces an application requires. Only six header files are installed in GNU ZRTP's include directory (libzrtpcpp subdirectory in the usual include paths) -== Demo program == +### Demo program ### The new folder ''demo'' contains a small demo program that shows various ways how to use GNU ZRTP to setup secure RTP (SRTP) sessions diff --git a/README.md b/README.md index f7b9966..8845777 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ functions for these enhanced features. **Note:** The Elliptic curves Cure25519 and Curve3617 are available only if you select the crypto standalone mode during build. -The newer verisons (starting with 4.1) implement an extensible mechanisms to +The newer versions (starting with 4.1) implement an extensible mechanisms to define algorithm selection policies that control selection of Hash, symmetric cipher, and the SRTP authentication. Currently two policies exist: _Standard_ and _PreferNonNist_. The Standard policy selects algorihms based on the @@ -39,6 +39,10 @@ non-NIST algorithms, for example Skein and Twofish, if the selected public key (Diffie-Hellman) algorithm is also one of the non-NIST algorithms. This is fully backward compatible and in-line with RFC6189. +Refer to new [NEWS][] file for a summary of changes. + +[NEWS]: NEWS.md + ### SDES support This release also provides SDES support. The SDES implementation does not support all of the fancy stuff but is usable in most cases. This implementation @@ -62,7 +66,7 @@ course some Java adaptation were done, for example to overcome the problem of non-existing pointers :-), thus I use some non-obvious array handling. If you are interessted in the Java implementation of ZRTP then you may have a look [here][javazrtp]. The Jitsi project uses the Java implementation. Jitsi is a -powerfull communication client and is definitely worth a [look][jitsi]. +powerful communication client and is definitely worth a [look][jitsi]. To enable C based code to use ZRTP C++ I did a C wrapper that offers the same functionality to C based RTP implementations. The first use of the ZRTP C @@ -152,4 +156,4 @@ and may give you an idea how to do it for other clients. The generated `Android.mk` generates `buildinfo_*.c` files in the root directory. You may delete these files after the Android static libraries are ready. -Since version 4.1.1 the example Android build files require NDK r9c. +Since version 4.1.1 the example Android build files require NDK r9c or better. diff --git a/clients/tivi/CtZrtpSession.cpp b/clients/tivi/CtZrtpSession.cpp index a2f3aa9..be4f672 100644 --- a/clients/tivi/CtZrtpSession.cpp +++ b/clients/tivi/CtZrtpSession.cpp @@ -129,12 +129,12 @@ void *findGlobalCfgKey(char *key, int iKeyLen, int &iSize, char **opt, int *type int iSZ; char *opt; int type; - void zrtp_log( const char *tag, const char *buf); int b32sas = 0, iDisableDH2K = 0, iDisableAES256 = 0, iPreferDH2K = 0; int iDisableECDH256 = 0, iDisableECDH384 = 0, iEnableSHA384 = 1; int iDisableSkein = 0, iDisableTwofish = 0, iPreferNIST = 0; int iDisableSkeinHash = 0, iDisableBernsteinCurve25519 = 0, iDisableBernsteinCurve3617 = 0; + int iEnableDisclosure = 0; GET_CFG_I(b32sas, "iDisable256SAS"); GET_CFG_I(iDisableAES256, "iDisableAES256"); @@ -151,6 +151,7 @@ void *findGlobalCfgKey(char *key, int iKeyLen, int &iSize, char **opt, int *type GET_CFG_I(iDisableSkeinHash, "iDisableSkeinHash"); GET_CFG_I(iDisableBernsteinCurve25519, "iDisableBernsteinCurve25519"); GET_CFG_I(iDisableBernsteinCurve3617, "iDisableBernsteinCurve3617"); + GET_CFG_I(iEnableDisclosure, "iEnableDisclosure"); conf->clear(); @@ -161,6 +162,10 @@ void *findGlobalCfgKey(char *key, int iKeyLen, int &iSize, char **opt, int *type */ conf->setSelectionPolicy(ZrtpConfigure::PreferNonNist); + // Set the Disclosure flag if the client SW has DR active. + if (iEnableDisclosure == 1) + conf->setDisclosureFlag(true); + /* * Handling of iPreferNIST: if this is false (== 0) then we add the non-NIST algorithms * to the configuration and place them in front of the NIST algorithms. Refer to RFC6189 diff --git a/clients/tivi/CtZrtpStream.cpp b/clients/tivi/CtZrtpStream.cpp index 0f1f21e..bfa6da0 100644 --- a/clients/tivi/CtZrtpStream.cpp +++ b/clients/tivi/CtZrtpStream.cpp @@ -71,7 +71,7 @@ void set_zrtp_log_cb(void *pRet, void (*cb)(void *ret, const char *tag, const ch } // This function is static (could be global) to reduce visibility -static void zrtp_log( const char *tag, const char *buf){ +/*static*/ void zrtp_log( const char *tag, const char *buf){ if(_zrtp_log_cb){ _zrtp_log_cb(pLogRet, tag, buf); } @@ -495,6 +495,7 @@ int CtZrtpStream::getInfo(const char *key, char *p, int maxLen) { secState |= 0x100; T_ZRTP_I("sec_state", secState); + T_ZRTP_I("peerDisclosureFlag", zrtpEngine->isPeerDisclosureFlag()? 1 : 0); T_ZRTP_LB("buildInfo", zrtpBuildInfo); // Compute Hello-hash info string diff --git a/zrtp/ZRtp.cpp b/zrtp/ZRtp.cpp index 78c3b39..35a3fb1 100755 --- a/zrtp/ZRtp.cpp +++ b/zrtp/ZRtp.cpp @@ -80,7 +80,8 @@ ZRtp::ZRtp(uint8_t *myZid, ZrtpCallback *cb, std::string id, ZrtpConfigure* conf callback(cb), dhContext(NULL), DHss(NULL), auxSecret(NULL), auxSecretLength(0), rs1Valid(false), rs2Valid(false), msgShaContext(NULL), hash(NULL), cipher(NULL), pubKey(NULL), sasType(NULL), authLength(NULL), multiStream(false), multiStreamAvailable(false), peerIsEnrolled(false), mitmSeen(false), pbxSecretTmp(NULL), - enrollmentMode(false), configureAlgos(*config), zidRec(NULL), saveZidRecord(true), masterStream(NULL) { + enrollmentMode(false), configureAlgos(*config), zidRec(NULL), saveZidRecord(true), signSasSeen(false), + masterStream(NULL), peerDisclosureFlagSeen(false) { #ifdef ZRTP_SAS_RELAY_SUPPORT enableMitmEnrollment = config->isTrustedMitM(); @@ -796,6 +797,9 @@ ZrtpPacketConfirm* ZRtp::prepareConfirm1(ZrtpPacketDHPart* dhPart2, uint32_t* er if (zidRec->isSasVerified() && !paranoidMode) { zrtpConfirm1.setSASFlag(); } + if (configureAlgos.isDisclosureFlag()) { + zrtpConfirm1.setDisclosureFlag(); + } zrtpConfirm1.setExpTime(0xFFFFFFFF); zrtpConfirm1.setIv(randomIV); zrtpConfirm1.setHashH0(H0); @@ -924,6 +928,9 @@ ZrtpPacketConfirm* ZRtp::prepareConfirm1MultiStream(ZrtpPacketCommit* commit, ui // Fill in Confirm1 packet. zrtpConfirm1.setMessageType((uint8_t*)Confirm1Msg); + if (configureAlgos.isDisclosureFlag()) { + zrtpConfirm1.setDisclosureFlag(); + } zrtpConfirm1.setExpTime(0xFFFFFFFF); zrtpConfirm1.setIv(randomIV); zrtpConfirm1.setHashH0(H0); @@ -991,6 +998,10 @@ ZrtpPacketConfirm* ZRtp::prepareConfirm2(ZrtpPacketConfirm* confirm1, uint32_t* if (!sasFlag || paranoidMode) { zidRec->resetSasVerified(); } + + // Store the status of the Disclosure flag + peerDisclosureFlagSeen = confirm1->isDisclosureFlag(); + // get verified flag from current RS1 before set a new RS1. This // may not be set even if peer's flag is set in confirm1 message. sasFlag = zidRec->isSasVerified(); @@ -1012,6 +1023,9 @@ ZrtpPacketConfirm* ZRtp::prepareConfirm2(ZrtpPacketConfirm* confirm1, uint32_t* if (sasFlag) { zrtpConfirm2.setSASFlag(); } + if (configureAlgos.isDisclosureFlag()) { + zrtpConfirm2.setDisclosureFlag(); + } zrtpConfirm2.setExpTime(0xFFFFFFFF); zrtpConfirm2.setIv(randomIV); @@ -1122,8 +1136,14 @@ ZrtpPacketConfirm* ZRtp::prepareConfirm2MultiStream(ZrtpPacketConfirm* confirm1, *errMsg = CriticalSWError; return NULL; } + // Store the status of the Disclosure flag + peerDisclosureFlagSeen = confirm1->isDisclosureFlag(); + // now generate my Confirm2 message zrtpConfirm2.setMessageType((uint8_t*)Confirm2Msg); + if (configureAlgos.isDisclosureFlag()) { + zrtpConfirm2.setDisclosureFlag(); + } zrtpConfirm2.setHashH0(H0); zrtpConfirm2.setExpTime(0xFFFFFFFF); zrtpConfirm2.setIv(randomIV); @@ -1230,6 +1250,9 @@ ZrtpPacketConf2Ack* ZRtp::prepareConf2Ack(ZrtpPacketConfirm *confirm2, uint32_t* return NULL; } } + // Store the status of the Disclosure flag + peerDisclosureFlagSeen = confirm2->isDisclosureFlag(); + return &zrtpConf2Ack; } diff --git a/zrtp/ZrtpConfigure.cpp b/zrtp/ZrtpConfigure.cpp index c63e44c..810df1a 100644 --- a/zrtp/ZrtpConfigure.cpp +++ b/zrtp/ZrtpConfigure.cpp @@ -490,6 +490,14 @@ bool ZrtpConfigure::isParanoidMode() { return enableParanoidMode; } +void ZrtpConfigure::setDisclosureFlag(bool yesNo) { + enableDisclosureFlag = yesNo; +} + +bool ZrtpConfigure::isDisclosureFlag() { + return enableDisclosureFlag; +} + #if 0 ZrtpConfigure config; diff --git a/zrtp/libzrtpcpp/ZRtp.h b/zrtp/libzrtpcpp/ZRtp.h index df5115d..368b3e8 100644 --- a/zrtp/libzrtpcpp/ZRtp.h +++ b/zrtp/libzrtpcpp/ZRtp.h @@ -692,6 +692,11 @@ class __EXPORT ZRtp { */ int32_t getZrtpRole() { return myRole; } + /** + * @brief Get status of our peer's disclosure flag + */ + bool isPeerDisclosureFlag(){ return peerDisclosureFlagSeen; } + private: typedef union _hashCtx { SkeinCtx_t skeinCtx; @@ -1022,7 +1027,7 @@ class __EXPORT ZRtp { /** * Save record * - * If false don't save record until user vrified and confirmed the SAS. + * If false don't save record until user verified and confirmed the SAS. */ bool saveZidRecord; /** @@ -1084,6 +1089,11 @@ class __EXPORT ZRtp { */ bool paranoidMode; + /** + * Is true if the other peer sent a Disclosure flag in its Confirm packet. + */ + bool peerDisclosureFlagSeen; + /** * Find the best Hash algorithm that is offered in Hello. * diff --git a/zrtp/libzrtpcpp/ZrtpConfigure.h b/zrtp/libzrtpcpp/ZrtpConfigure.h index bb78cef..887c124 100644 --- a/zrtp/libzrtpcpp/ZrtpConfigure.h +++ b/zrtp/libzrtpcpp/ZrtpConfigure.h @@ -515,6 +515,24 @@ class __EXPORT ZrtpConfigure { */ bool isParanoidMode(); + /** + * Enables or disables setting of Disclosure flag. + * + * For further explanation of the disclosure flage refer to RFC6189, chaper 11 + * + * @param yesNo + * If set to true then set the disclosure flag in confirm packets. + */ + void setDisclosureFlag(bool yesNo); + + /** + * Check if the protocol should set the disclosure flag. + * + * @return + * Returns true if disclosure falg should be set. + */ + bool isDisclosureFlag(); + /// Helper function to print some internal data void printConfiguredAlgos(AlgoTypes algoTyp); @@ -531,6 +549,7 @@ class __EXPORT ZrtpConfigure { bool enableTrustedMitM; bool enableSasSignature; bool enableParanoidMode; + bool enableDisclosureFlag; AlgorithmEnum& getAlgoAt(std::vector<AlgorithmEnum* >& a, int32_t index); diff --git a/zrtp/libzrtpcpp/ZrtpPacketConfirm.h b/zrtp/libzrtpcpp/ZrtpPacketConfirm.h index ab0352b..3601d8b 100644 --- a/zrtp/libzrtpcpp/ZrtpPacketConfirm.h +++ b/zrtp/libzrtpcpp/ZrtpPacketConfirm.h @@ -58,10 +58,13 @@ class __EXPORT ZrtpPacketConfirm : public ZrtpPacketBase { virtual ~ZrtpPacketConfirm(); /// Check if SAS verify flag is set - const bool isSASFlag() { return (confirmHeader->flags & 0x4) == 0x4 ? true : false; } + const bool isSASFlag() { return (confirmHeader->flags & 0x4) == 0x4; } + + /// Check if SAS verify flag is set + const bool isDisclosureFlag() { return (confirmHeader->flags & 0x4) == 0x1; } /// Check if PBXEnrollment flag is set - const bool isPBXEnrollment() { return (confirmHeader->flags & 0x8) == 0x8 ? true : false; } + const bool isPBXEnrollment() { return (confirmHeader->flags & 0x8) == 0x8; } /// Get pointer to filler bytes (contains one bit of signature length) const uint8_t* getFiller() { return confirmHeader->filler; } @@ -92,6 +95,9 @@ class __EXPORT ZrtpPacketConfirm : public ZrtpPacketBase { /// set SAS verified flag void setSASFlag() { confirmHeader->flags |= 0x4; } + /// set Disclosure flag + void setDisclosureFlag() { confirmHeader->flags |= 0x1; } + /// set setPBXEnrollment flag void setPBXEnrollment() { confirmHeader->flags |= 0x8; }
0
95294bbf4d3551dc913cbb2aeb461a75f1c749d2
https://github.com/omphalos/crud-file-server/commit/95294bbf4d3551dc913cbb2aeb461a75f1c749d2
Remove node version
diff --git a/package.json b/package.json index 35ee0d3..106c61e 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,5 @@ "mime": "1.2.7" }, "license": "unlicense", - "engine": { - "node": ">=0.8.1" - }, "author": "omphalos" }
0
ba52a3de3247fdb5649fac671fa4d8de5c0b654a
https://github.com/libjpeg-turbo/libjpeg-turbo/commit/ba52a3de3247fdb5649fac671fa4d8de5c0b654a
Neon: Intrinsics impl of h2v1 & h2v2 merged upsamp There was no previous GAS implementation. This commit also reverts 40557b23015d2f8b576420231b8dd1f39f2ceed8 and 7723d7f7d0aa40349d5bdd1fbe4f8631fd5a2b57. 7723d7f7d0aa40349d5bdd1fbe4f8631fd5a2b57 was only necessary because there was no Neon implementation of merged upsampling/color conversion, and 40557b23015d2f8b576420231b8dd1f39f2ceed8 was only necessary because of 7723d7f7d0aa40349d5bdd1fbe4f8631fd5a2b57.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dac532bc..49c4f9033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -800,29 +800,7 @@ else() set(MD5_PPM_3x2_IFAST fd283664b3b49127984af0a7f118fccd) set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1) set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617) - # Since v1.5.1, libjpeg-turbo uses the separate non-fancy upsampling and - # YCbCr -> RGB color conversion routines rather than merged upsampling/color - # conversion when fancy upsampling is disabled on platforms that have a SIMD - # implementation of YCbCr -> RGB color conversion but no SIMD implementation - # of merged upsampling/color conversion. This was intended to improve the - # performance of the Arm Neon SIMD extensions, the only SIMD extensions for - # which those circumstances currently apply. The separate non-fancy - # upsampling and color conversion routines usually produce bitwise-identical - # output to the merged upsampling/color conversion routines, but that is not - # the case when skipping scanlines starting at an odd-numbered scanline. In - # libjpeg-turbo 2.0.5 and prior, doing that while using merged h2v2 - # upsampling caused a segfault, so this test validates the fix for that - # segfault. Unfortunately, however, the test also produces different bitwise - # output when using the Neon SIMD extensions, because of the aforementioned - # optimization. The easiest workaround is to use the old test from - # libjpeg-turbo 2.0.5 and prior when using the Neon SIMD extensions. The - # aforementioned segfault never would have occurred with the Neon SIMD - # extensions anyhow, since merged upsampling is disabled when using them. - if((CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") AND WITH_SIMD) - set(MD5_PPM_420M_IFAST_ARI 72b59a99bcf1de24c5b27d151bde2437) - else() - set(MD5_PPM_420M_IFAST_ARI 57251da28a35b46eecb7177d82d10e0e) - endif() + set(MD5_PPM_420M_IFAST_ARI 57251da28a35b46eecb7177d82d10e0e) set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f) set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9) set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7) @@ -1223,17 +1201,9 @@ foreach(libtype ${TEST_LIBTYPES}) if(WITH_ARITH_DEC) # CC: RGB->YCC SAMP: h2v2 merged IDCT: ifast ENT: arith - if((CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") AND WITH_SIMD) - # Refer to the comment above the definition of MD5_PPM_420M_IFAST_ARI for - # an explanation of why this is necessary. - add_bittest(djpeg 420m-ifast-ari "-fast;-ppm" - testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg - ${MD5_PPM_420M_IFAST_ARI}) - else() - add_bittest(djpeg 420m-ifast-ari "-fast;-skip;1,20;-ppm" - testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg - ${MD5_PPM_420M_IFAST_ARI}) - endif() + add_bittest(djpeg 420m-ifast-ari "-fast;-skip;1,20;-ppm" + testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg + ${MD5_PPM_420M_IFAST_ARI}) add_bittest(jpegtran 420-islow "" testout_420_islow.jpg ${TESTIMAGES}/testimgari.jpg diff --git a/jdmaster.c b/jdmaster.c index bc39d1c71..cbc8774b1 100644 --- a/jdmaster.c +++ b/jdmaster.c @@ -22,7 +22,6 @@ #include "jpeglib.h" #include "jpegcomp.h" #include "jdmaster.h" -#include "jsimd.h" /* @@ -70,17 +69,6 @@ use_merged_upsample(j_decompress_ptr cinfo) cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size || cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size) return FALSE; -#ifdef WITH_SIMD - /* If YCbCr-to-RGB color conversion is SIMD-accelerated but merged upsampling - isn't, then disabling merged upsampling is likely to be faster when - decompressing YCbCr JPEG images. */ - if (!jsimd_can_h2v2_merged_upsample() && !jsimd_can_h2v1_merged_upsample() && - jsimd_can_ycc_rgb() && cinfo->jpeg_color_space == JCS_YCbCr && - (cinfo->out_color_space == JCS_RGB || - (cinfo->out_color_space >= JCS_EXT_RGB && - cinfo->out_color_space <= JCS_EXT_ARGB))) - return FALSE; -#endif /* ??? also need to test for upsample-time rescaling, when & if supported */ return TRUE; /* by golly, it'll work... */ #else diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt index f976417a8..22a887dab 100644 --- a/simd/CMakeLists.txt +++ b/simd/CMakeLists.txt @@ -266,7 +266,8 @@ endif() file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/gastest.S) set(SIMD_SOURCES arm/jcgray-neon.c arm/jcphuff-neon.c arm/jcsample-neon.c - arm/jdsample-neon.c arm/jfdctfst-neon.c arm/jquanti-neon.c) + arm/jdmerge-neon.c arm/jdsample-neon.c arm/jfdctfst-neon.c + arm/jquanti-neon.c) if(NEON_INTRINSICS) set(SIMD_SOURCES ${SIMD_SOURCES} arm/jccolor-neon.c arm/jidctint-neon.c) endif() diff --git a/simd/arm/aarch32/jsimd.c b/simd/arm/aarch32/jsimd.c index e054a453b..df13c1199 100644 --- a/simd/arm/aarch32/jsimd.c +++ b/simd/arm/aarch32/jsimd.c @@ -501,12 +501,34 @@ jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, GLOBAL(int) jsimd_can_h2v2_merged_upsample(void) { + init_simd(); + + /* The code is optimised for these values only */ + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + + if (simd_support & JSIMD_NEON) + return 1; + return 0; } GLOBAL(int) jsimd_can_h2v1_merged_upsample(void) { + init_simd(); + + /* The code is optimised for these values only */ + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + + if (simd_support & JSIMD_NEON) + return 1; + return 0; } @@ -514,12 +536,74 @@ GLOBAL(void) jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) { + void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); + + switch (cinfo->out_color_space) { + case JCS_EXT_RGB: + neonfct = jsimd_h2v2_extrgb_merged_upsample_neon; + break; + case JCS_EXT_RGBX: + case JCS_EXT_RGBA: + neonfct = jsimd_h2v2_extrgbx_merged_upsample_neon; + break; + case JCS_EXT_BGR: + neonfct = jsimd_h2v2_extbgr_merged_upsample_neon; + break; + case JCS_EXT_BGRX: + case JCS_EXT_BGRA: + neonfct = jsimd_h2v2_extbgrx_merged_upsample_neon; + break; + case JCS_EXT_XBGR: + case JCS_EXT_ABGR: + neonfct = jsimd_h2v2_extxbgr_merged_upsample_neon; + break; + case JCS_EXT_XRGB: + case JCS_EXT_ARGB: + neonfct = jsimd_h2v2_extxrgb_merged_upsample_neon; + break; + default: + neonfct = jsimd_h2v2_extrgb_merged_upsample_neon; + break; + } + + neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); } GLOBAL(void) jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) { + void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); + + switch (cinfo->out_color_space) { + case JCS_EXT_RGB: + neonfct = jsimd_h2v1_extrgb_merged_upsample_neon; + break; + case JCS_EXT_RGBX: + case JCS_EXT_RGBA: + neonfct = jsimd_h2v1_extrgbx_merged_upsample_neon; + break; + case JCS_EXT_BGR: + neonfct = jsimd_h2v1_extbgr_merged_upsample_neon; + break; + case JCS_EXT_BGRX: + case JCS_EXT_BGRA: + neonfct = jsimd_h2v1_extbgrx_merged_upsample_neon; + break; + case JCS_EXT_XBGR: + case JCS_EXT_ABGR: + neonfct = jsimd_h2v1_extxbgr_merged_upsample_neon; + break; + case JCS_EXT_XRGB: + case JCS_EXT_ARGB: + neonfct = jsimd_h2v1_extxrgb_merged_upsample_neon; + break; + default: + neonfct = jsimd_h2v1_extrgb_merged_upsample_neon; + break; + } + + neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); } GLOBAL(int) diff --git a/simd/arm/aarch64/jsimd.c b/simd/arm/aarch64/jsimd.c index a507c2ced..74cd6ccad 100644 --- a/simd/arm/aarch64/jsimd.c +++ b/simd/arm/aarch64/jsimd.c @@ -569,12 +569,34 @@ jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, GLOBAL(int) jsimd_can_h2v2_merged_upsample(void) { + init_simd(); + + /* The code is optimised for these values only */ + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + + if (simd_support & JSIMD_NEON) + return 1; + return 0; } GLOBAL(int) jsimd_can_h2v1_merged_upsample(void) { + init_simd(); + + /* The code is optimised for these values only */ + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + + if (simd_support & JSIMD_NEON) + return 1; + return 0; } @@ -582,12 +604,74 @@ GLOBAL(void) jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) { + void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); + + switch (cinfo->out_color_space) { + case JCS_EXT_RGB: + neonfct = jsimd_h2v2_extrgb_merged_upsample_neon; + break; + case JCS_EXT_RGBX: + case JCS_EXT_RGBA: + neonfct = jsimd_h2v2_extrgbx_merged_upsample_neon; + break; + case JCS_EXT_BGR: + neonfct = jsimd_h2v2_extbgr_merged_upsample_neon; + break; + case JCS_EXT_BGRX: + case JCS_EXT_BGRA: + neonfct = jsimd_h2v2_extbgrx_merged_upsample_neon; + break; + case JCS_EXT_XBGR: + case JCS_EXT_ABGR: + neonfct = jsimd_h2v2_extxbgr_merged_upsample_neon; + break; + case JCS_EXT_XRGB: + case JCS_EXT_ARGB: + neonfct = jsimd_h2v2_extxrgb_merged_upsample_neon; + break; + default: + neonfct = jsimd_h2v2_extrgb_merged_upsample_neon; + break; + } + + neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); } GLOBAL(void) jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) { + void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); + + switch (cinfo->out_color_space) { + case JCS_EXT_RGB: + neonfct = jsimd_h2v1_extrgb_merged_upsample_neon; + break; + case JCS_EXT_RGBX: + case JCS_EXT_RGBA: + neonfct = jsimd_h2v1_extrgbx_merged_upsample_neon; + break; + case JCS_EXT_BGR: + neonfct = jsimd_h2v1_extbgr_merged_upsample_neon; + break; + case JCS_EXT_BGRX: + case JCS_EXT_BGRA: + neonfct = jsimd_h2v1_extbgrx_merged_upsample_neon; + break; + case JCS_EXT_XBGR: + case JCS_EXT_ABGR: + neonfct = jsimd_h2v1_extxbgr_merged_upsample_neon; + break; + case JCS_EXT_XRGB: + case JCS_EXT_ARGB: + neonfct = jsimd_h2v1_extxrgb_merged_upsample_neon; + break; + default: + neonfct = jsimd_h2v1_extrgb_merged_upsample_neon; + break; + } + + neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); } GLOBAL(int) diff --git a/simd/arm/jdmerge-neon.c b/simd/arm/jdmerge-neon.c new file mode 100644 index 000000000..18fb9d8a5 --- /dev/null +++ b/simd/arm/jdmerge-neon.c @@ -0,0 +1,144 @@ +/* + * jdmerge-neon.c - merged upsampling/color conversion (Arm Neon) + * + * Copyright (C) 2020, Arm Limited. All Rights Reserved. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#define JPEG_INTERNALS +#include "../../jinclude.h" +#include "../../jpeglib.h" +#include "../../jsimd.h" +#include "../../jdct.h" +#include "../../jsimddct.h" +#include "../jsimd.h" +#include "align.h" + +#include <arm_neon.h> + + +/* YCbCr -> RGB conversion constants */ + +#define F_0_344 11277 /* 0.3441467 = 11277 * 2^-15 */ +#define F_0_714 23401 /* 0.7141418 = 23401 * 2^-15 */ +#define F_1_402 22971 /* 1.4020386 = 22971 * 2^-14 */ +#define F_1_772 29033 /* 1.7720337 = 29033 * 2^-14 */ + +ALIGN(16) static const int16_t jsimd_ycc_rgb_convert_neon_consts[] = { + -F_0_344, F_0_714, F_1_402, F_1_772 +}; + + +/* Include inline routines for colorspace extensions. */ + +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_PIXELSIZE + +#define RGB_RED EXT_RGB_RED +#define RGB_GREEN EXT_RGB_GREEN +#define RGB_BLUE EXT_RGB_BLUE +#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE +#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extrgb_merged_upsample_neon +#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extrgb_merged_upsample_neon +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_PIXELSIZE +#undef jsimd_h2v1_merged_upsample_neon +#undef jsimd_h2v2_merged_upsample_neon + +#define RGB_RED EXT_RGBX_RED +#define RGB_GREEN EXT_RGBX_GREEN +#define RGB_BLUE EXT_RGBX_BLUE +#define RGB_ALPHA 3 +#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE +#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extrgbx_merged_upsample_neon +#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extrgbx_merged_upsample_neon +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_ALPHA +#undef RGB_PIXELSIZE +#undef jsimd_h2v1_merged_upsample_neon +#undef jsimd_h2v2_merged_upsample_neon + +#define RGB_RED EXT_BGR_RED +#define RGB_GREEN EXT_BGR_GREEN +#define RGB_BLUE EXT_BGR_BLUE +#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE +#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extbgr_merged_upsample_neon +#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extbgr_merged_upsample_neon +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_PIXELSIZE +#undef jsimd_h2v1_merged_upsample_neon +#undef jsimd_h2v2_merged_upsample_neon + +#define RGB_RED EXT_BGRX_RED +#define RGB_GREEN EXT_BGRX_GREEN +#define RGB_BLUE EXT_BGRX_BLUE +#define RGB_ALPHA 3 +#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE +#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extbgrx_merged_upsample_neon +#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extbgrx_merged_upsample_neon +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_ALPHA +#undef RGB_PIXELSIZE +#undef jsimd_h2v1_merged_upsample_neon +#undef jsimd_h2v2_merged_upsample_neon + +#define RGB_RED EXT_XBGR_RED +#define RGB_GREEN EXT_XBGR_GREEN +#define RGB_BLUE EXT_XBGR_BLUE +#define RGB_ALPHA 0 +#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE +#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extxbgr_merged_upsample_neon +#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extxbgr_merged_upsample_neon +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_ALPHA +#undef RGB_PIXELSIZE +#undef jsimd_h2v1_merged_upsample_neon +#undef jsimd_h2v2_merged_upsample_neon + +#define RGB_RED EXT_XRGB_RED +#define RGB_GREEN EXT_XRGB_GREEN +#define RGB_BLUE EXT_XRGB_BLUE +#define RGB_ALPHA 0 +#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE +#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extxrgb_merged_upsample_neon +#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extxrgb_merged_upsample_neon +#include "jdmrgext-neon.c" +#undef RGB_RED +#undef RGB_GREEN +#undef RGB_BLUE +#undef RGB_ALPHA +#undef RGB_PIXELSIZE +#undef jsimd_h2v1_merged_upsample_neon diff --git a/simd/arm/jdmrgext-neon.c b/simd/arm/jdmrgext-neon.c new file mode 100644 index 000000000..fa2ec056a --- /dev/null +++ b/simd/arm/jdmrgext-neon.c @@ -0,0 +1,667 @@ +/* + * jdmrgext-neon.c - merged upsampling/color conversion (Arm Neon) + * + * Copyright (C) 2020, Arm Limited. All Rights Reserved. + * Copyright (C) 2020, D. R. Commander. All Rights Reserved. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +/* This file is included by jdmerge-neon.c. */ + + +/* These routines combine simple (non-fancy, i.e. non-smooth) h2v1 or h2v2 + * chroma upsampling and YCbCr -> RGB color conversion into a single function. + * + * As with the standalone functions, YCbCr -> RGB conversion is defined by the + * following equations: + * R = Y + 1.40200 * (Cr - 128) + * G = Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) + * B = Y + 1.77200 * (Cb - 128) + * + * Scaled integer constants are used to avoid floating-point arithmetic: + * 0.3441467 = 11277 * 2^-15 + * 0.7141418 = 23401 * 2^-15 + * 1.4020386 = 22971 * 2^-14 + * 1.7720337 = 29033 * 2^-14 + * These constants are defined in jdmerge-neon.c. + * + * To ensure correct results, rounding is used when descaling. + */ + +/* Notes on safe memory access for merged upsampling/YCbCr -> RGB conversion + * routines: + * + * Input memory buffers can be safely overread up to the next multiple of + * ALIGN_SIZE bytes, since they are always allocated by alloc_sarray() in + * jmemmgr.c. + * + * The output buffer cannot safely be written beyond output_width, since + * output_buf points to a possibly unpadded row in the decompressed image + * buffer allocated by the calling program. + */ + +/* Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. + */ + +void jsimd_h2v1_merged_upsample_neon(JDIMENSION output_width, + JSAMPIMAGE input_buf, + JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + JSAMPROW outptr; + /* Pointers to Y, Cb, and Cr data */ + JSAMPROW inptr0, inptr1, inptr2; + + const int16x4_t consts = vld1_s16(jsimd_ycc_rgb_convert_neon_consts); + const int16x8_t neg_128 = vdupq_n_s16(-128); + + inptr0 = input_buf[0][in_row_group_ctr]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr = output_buf[0]; + + int cols_remaining = output_width; + for (; cols_remaining >= 16; cols_remaining -= 16) { + /* De-interleave Y component values into two separate vectors, one + * containing the component values with even-numbered indices and one + * containing the component values with odd-numbered indices. + */ + uint8x8x2_t y = vld2_u8(inptr0); + uint8x8_t cb = vld1_u8(inptr1); + uint8x8_t cr = vld1_u8(inptr2); + /* Subtract 128 from Cb and Cr. */ + int16x8_t cr_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr)); + int16x8_t cb_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb)); + /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */ + int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0); + int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0); + g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1); + g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1); + /* Descale G components: shift right 15, round, and narrow to 16-bit. */ + int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15), + vrshrn_n_s32(g_sub_y_h, 15)); + /* Compute R-Y: 1.40200 * (Cr - 128) */ + int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2); + /* Compute B-Y: 1.77200 * (Cb - 128) */ + int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3); + /* Add the chroma-derived values (G-Y, R-Y, and B-Y) to both the "even" and + * "odd" Y component values. This effectively upsamples the chroma + * components horizontally. + */ + int16x8_t g_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y.val[0])); + int16x8_t r_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y.val[0])); + int16x8_t b_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y.val[0])); + int16x8_t g_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y.val[1])); + int16x8_t r_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y.val[1])); + int16x8_t b_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y.val[1])); + /* Convert each component to unsigned and narrow, clamping to [0-255]. + * Re-interleave the "even" and "odd" component values. + */ + uint8x8x2_t r = vzip_u8(vqmovun_s16(r_even), vqmovun_s16(r_odd)); + uint8x8x2_t g = vzip_u8(vqmovun_s16(g_even), vqmovun_s16(g_odd)); + uint8x8x2_t b = vzip_u8(vqmovun_s16(b_even), vqmovun_s16(b_odd)); + +#ifdef RGB_ALPHA + uint8x16x4_t rgba; + rgba.val[RGB_RED] = vcombine_u8(r.val[0], r.val[1]); + rgba.val[RGB_GREEN] = vcombine_u8(g.val[0], g.val[1]); + rgba.val[RGB_BLUE] = vcombine_u8(b.val[0], b.val[1]); + /* Set alpha channel to opaque (0xFF). */ + rgba.val[RGB_ALPHA] = vdupq_n_u8(0xFF); + /* Store RGBA pixel data to memory. */ + vst4q_u8(outptr, rgba); +#else + uint8x16x3_t rgb; + rgb.val[RGB_RED] = vcombine_u8(r.val[0], r.val[1]); + rgb.val[RGB_GREEN] = vcombine_u8(g.val[0], g.val[1]); + rgb.val[RGB_BLUE] = vcombine_u8(b.val[0], b.val[1]); + /* Store RGB pixel data to memory. */ + vst3q_u8(outptr, rgb); +#endif + + /* Increment pointers. */ + inptr0 += 16; + inptr1 += 8; + inptr2 += 8; + outptr += (RGB_PIXELSIZE * 16); + } + + if (cols_remaining > 0) { + /* De-interleave Y component values into two separate vectors, one + * containing the component values with even-numbered indices and one + * containing the component values with odd-numbered indices. + */ + uint8x8x2_t y = vld2_u8(inptr0); + uint8x8_t cb = vld1_u8(inptr1); + uint8x8_t cr = vld1_u8(inptr2); + /* Subtract 128 from Cb and Cr. */ + int16x8_t cr_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr)); + int16x8_t cb_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb)); + /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */ + int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0); + int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0); + g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1); + g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1); + /* Descale G components: shift right 15, round, and narrow to 16-bit. */ + int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15), + vrshrn_n_s32(g_sub_y_h, 15)); + /* Compute R-Y: 1.40200 * (Cr - 128) */ + int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2); + /* Compute B-Y: 1.77200 * (Cb - 128) */ + int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3); + /* Add the chroma-derived values (G-Y, R-Y, and B-Y) to both the "even" and + * "odd" Y component values. This effectively upsamples the chroma + * components horizontally. + */ + int16x8_t g_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y.val[0])); + int16x8_t r_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y.val[0])); + int16x8_t b_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y.val[0])); + int16x8_t g_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y.val[1])); + int16x8_t r_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y.val[1])); + int16x8_t b_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y.val[1])); + /* Convert each component to unsigned and narrow, clamping to [0-255]. + * Re-interleave the "even" and "odd" component values. + */ + uint8x8x2_t r = vzip_u8(vqmovun_s16(r_even), vqmovun_s16(r_odd)); + uint8x8x2_t g = vzip_u8(vqmovun_s16(g_even), vqmovun_s16(g_odd)); + uint8x8x2_t b = vzip_u8(vqmovun_s16(b_even), vqmovun_s16(b_odd)); + +#ifdef RGB_ALPHA + uint8x8x4_t rgba_h; + rgba_h.val[RGB_RED] = r.val[1]; + rgba_h.val[RGB_GREEN] = g.val[1]; + rgba_h.val[RGB_BLUE] = b.val[1]; + /* Set alpha channel to opaque (0xFF). */ + rgba_h.val[RGB_ALPHA] = vdup_n_u8(0xFF); + uint8x8x4_t rgba_l; + rgba_l.val[RGB_RED] = r.val[0]; + rgba_l.val[RGB_GREEN] = g.val[0]; + rgba_l.val[RGB_BLUE] = b.val[0]; + /* Set alpha channel to opaque (0xFF). */ + rgba_l.val[RGB_ALPHA] = vdup_n_u8(0xFF); + /* Store RGBA pixel data to memory. */ + switch (cols_remaining) { + case 15: + vst4_lane_u8(outptr + 14 * RGB_PIXELSIZE, rgba_h, 6); + case 14: + vst4_lane_u8(outptr + 13 * RGB_PIXELSIZE, rgba_h, 5); + case 13: + vst4_lane_u8(outptr + 12 * RGB_PIXELSIZE, rgba_h, 4); + case 12: + vst4_lane_u8(outptr + 11 * RGB_PIXELSIZE, rgba_h, 3); + case 11: + vst4_lane_u8(outptr + 10 * RGB_PIXELSIZE, rgba_h, 2); + case 10: + vst4_lane_u8(outptr + 9 * RGB_PIXELSIZE, rgba_h, 1); + case 9: + vst4_lane_u8(outptr + 8 * RGB_PIXELSIZE, rgba_h, 0); + case 8: + vst4_u8(outptr, rgba_l); + break; + case 7: + vst4_lane_u8(outptr + 6 * RGB_PIXELSIZE, rgba_l, 6); + case 6: + vst4_lane_u8(outptr + 5 * RGB_PIXELSIZE, rgba_l, 5); + case 5: + vst4_lane_u8(outptr + 4 * RGB_PIXELSIZE, rgba_l, 4); + case 4: + vst4_lane_u8(outptr + 3 * RGB_PIXELSIZE, rgba_l, 3); + case 3: + vst4_lane_u8(outptr + 2 * RGB_PIXELSIZE, rgba_l, 2); + case 2: + vst4_lane_u8(outptr + RGB_PIXELSIZE, rgba_l, 1); + case 1: + vst4_lane_u8(outptr, rgba_l, 0); + default: + break; + } +#else + uint8x8x3_t rgb_h; + rgb_h.val[RGB_RED] = r.val[1]; + rgb_h.val[RGB_GREEN] = g.val[1]; + rgb_h.val[RGB_BLUE] = b.val[1]; + uint8x8x3_t rgb_l; + rgb_l.val[RGB_RED] = r.val[0]; + rgb_l.val[RGB_GREEN] = g.val[0]; + rgb_l.val[RGB_BLUE] = b.val[0]; + /* Store RGB pixel data to memory. */ + switch (cols_remaining) { + case 15: + vst3_lane_u8(outptr + 14 * RGB_PIXELSIZE, rgb_h, 6); + case 14: + vst3_lane_u8(outptr + 13 * RGB_PIXELSIZE, rgb_h, 5); + case 13: + vst3_lane_u8(outptr + 12 * RGB_PIXELSIZE, rgb_h, 4); + case 12: + vst3_lane_u8(outptr + 11 * RGB_PIXELSIZE, rgb_h, 3); + case 11: + vst3_lane_u8(outptr + 10 * RGB_PIXELSIZE, rgb_h, 2); + case 10: + vst3_lane_u8(outptr + 9 * RGB_PIXELSIZE, rgb_h, 1); + case 9: + vst3_lane_u8(outptr + 8 * RGB_PIXELSIZE, rgb_h, 0); + case 8: + vst3_u8(outptr, rgb_l); + break; + case 7: + vst3_lane_u8(outptr + 6 * RGB_PIXELSIZE, rgb_l, 6); + case 6: + vst3_lane_u8(outptr + 5 * RGB_PIXELSIZE, rgb_l, 5); + case 5: + vst3_lane_u8(outptr + 4 * RGB_PIXELSIZE, rgb_l, 4); + case 4: + vst3_lane_u8(outptr + 3 * RGB_PIXELSIZE, rgb_l, 3); + case 3: + vst3_lane_u8(outptr + 2 * RGB_PIXELSIZE, rgb_l, 2); + case 2: + vst3_lane_u8(outptr + RGB_PIXELSIZE, rgb_l, 1); + case 1: + vst3_lane_u8(outptr, rgb_l, 0); + default: + break; + } +#endif + } +} + + +/* Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. + * + * See comments above for details regarding color conversion and safe memory + * access. + */ + +void jsimd_h2v2_merged_upsample_neon(JDIMENSION output_width, + JSAMPIMAGE input_buf, + JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + JSAMPROW outptr0, outptr1; + /* Pointers to Y (both rows), Cb, and Cr data */ + JSAMPROW inptr0_0, inptr0_1, inptr1, inptr2; + + const int16x4_t consts = vld1_s16(jsimd_ycc_rgb_convert_neon_consts); + const int16x8_t neg_128 = vdupq_n_s16(-128); + + inptr0_0 = input_buf[0][in_row_group_ctr * 2]; + inptr0_1 = input_buf[0][in_row_group_ctr * 2 + 1]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr0 = output_buf[0]; + outptr1 = output_buf[1]; + + int cols_remaining = output_width; + for (; cols_remaining >= 16; cols_remaining -= 16) { + /* For each row, de-interleave Y component values into two separate + * vectors, one containing the component values with even-numbered indices + * and one containing the component values with odd-numbered indices. + */ + uint8x8x2_t y0 = vld2_u8(inptr0_0); + uint8x8x2_t y1 = vld2_u8(inptr0_1); + uint8x8_t cb = vld1_u8(inptr1); + uint8x8_t cr = vld1_u8(inptr2); + /* Subtract 128 from Cb and Cr. */ + int16x8_t cr_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr)); + int16x8_t cb_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb)); + /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */ + int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0); + int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0); + g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1); + g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1); + /* Descale G components: shift right 15, round, and narrow to 16-bit. */ + int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15), + vrshrn_n_s32(g_sub_y_h, 15)); + /* Compute R-Y: 1.40200 * (Cr - 128) */ + int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2); + /* Compute B-Y: 1.77200 * (Cb - 128) */ + int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3); + /* For each row, add the chroma-derived values (G-Y, R-Y, and B-Y) to both + * the "even" and "odd" Y component values. This effectively upsamples the + * chroma components both horizontally and vertically. + */ + int16x8_t g0_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y0.val[0])); + int16x8_t r0_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y0.val[0])); + int16x8_t b0_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y0.val[0])); + int16x8_t g0_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y0.val[1])); + int16x8_t r0_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y0.val[1])); + int16x8_t b0_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y0.val[1])); + int16x8_t g1_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y1.val[0])); + int16x8_t r1_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y1.val[0])); + int16x8_t b1_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y1.val[0])); + int16x8_t g1_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y1.val[1])); + int16x8_t r1_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y1.val[1])); + int16x8_t b1_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y1.val[1])); + /* Convert each component to unsigned and narrow, clamping to [0-255]. + * Re-interleave the "even" and "odd" component values. + */ + uint8x8x2_t r0 = vzip_u8(vqmovun_s16(r0_even), vqmovun_s16(r0_odd)); + uint8x8x2_t r1 = vzip_u8(vqmovun_s16(r1_even), vqmovun_s16(r1_odd)); + uint8x8x2_t g0 = vzip_u8(vqmovun_s16(g0_even), vqmovun_s16(g0_odd)); + uint8x8x2_t g1 = vzip_u8(vqmovun_s16(g1_even), vqmovun_s16(g1_odd)); + uint8x8x2_t b0 = vzip_u8(vqmovun_s16(b0_even), vqmovun_s16(b0_odd)); + uint8x8x2_t b1 = vzip_u8(vqmovun_s16(b1_even), vqmovun_s16(b1_odd)); + +#ifdef RGB_ALPHA + uint8x16x4_t rgba0, rgba1; + rgba0.val[RGB_RED] = vcombine_u8(r0.val[0], r0.val[1]); + rgba1.val[RGB_RED] = vcombine_u8(r1.val[0], r1.val[1]); + rgba0.val[RGB_GREEN] = vcombine_u8(g0.val[0], g0.val[1]); + rgba1.val[RGB_GREEN] = vcombine_u8(g1.val[0], g1.val[1]); + rgba0.val[RGB_BLUE] = vcombine_u8(b0.val[0], b0.val[1]); + rgba1.val[RGB_BLUE] = vcombine_u8(b1.val[0], b1.val[1]); + /* Set alpha channel to opaque (0xFF). */ + rgba0.val[RGB_ALPHA] = vdupq_n_u8(0xFF); + rgba1.val[RGB_ALPHA] = vdupq_n_u8(0xFF); + /* Store RGBA pixel data to memory. */ + vst4q_u8(outptr0, rgba0); + vst4q_u8(outptr1, rgba1); +#else + uint8x16x3_t rgb0, rgb1; + rgb0.val[RGB_RED] = vcombine_u8(r0.val[0], r0.val[1]); + rgb1.val[RGB_RED] = vcombine_u8(r1.val[0], r1.val[1]); + rgb0.val[RGB_GREEN] = vcombine_u8(g0.val[0], g0.val[1]); + rgb1.val[RGB_GREEN] = vcombine_u8(g1.val[0], g1.val[1]); + rgb0.val[RGB_BLUE] = vcombine_u8(b0.val[0], b0.val[1]); + rgb1.val[RGB_BLUE] = vcombine_u8(b1.val[0], b1.val[1]); + /* Store RGB pixel data to memory. */ + vst3q_u8(outptr0, rgb0); + vst3q_u8(outptr1, rgb1); +#endif + + /* Increment pointers. */ + inptr0_0 += 16; + inptr0_1 += 16; + inptr1 += 8; + inptr2 += 8; + outptr0 += (RGB_PIXELSIZE * 16); + outptr1 += (RGB_PIXELSIZE * 16); + } + + if (cols_remaining > 0) { + /* For each row, de-interleave Y component values into two separate + * vectors, one containing the component values with even-numbered indices + * and one containing the component values with odd-numbered indices. + */ + uint8x8x2_t y0 = vld2_u8(inptr0_0); + uint8x8x2_t y1 = vld2_u8(inptr0_1); + uint8x8_t cb = vld1_u8(inptr1); + uint8x8_t cr = vld1_u8(inptr2); + /* Subtract 128 from Cb and Cr. */ + int16x8_t cr_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr)); + int16x8_t cb_128 = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb)); + /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */ + int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0); + int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0); + g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1); + g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1); + /* Descale G components: shift right 15, round, and narrow to 16-bit. */ + int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15), + vrshrn_n_s32(g_sub_y_h, 15)); + /* Compute R-Y: 1.40200 * (Cr - 128) */ + int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2); + /* Compute B-Y: 1.77200 * (Cb - 128) */ + int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3); + /* For each row, add the chroma-derived values (G-Y, R-Y, and B-Y) to both + * the "even" and "odd" Y component values. This effectively upsamples the + * chroma components both horizontally and vertically. + */ + int16x8_t g0_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y0.val[0])); + int16x8_t r0_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y0.val[0])); + int16x8_t b0_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y0.val[0])); + int16x8_t g0_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y0.val[1])); + int16x8_t r0_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y0.val[1])); + int16x8_t b0_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y0.val[1])); + int16x8_t g1_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y1.val[0])); + int16x8_t r1_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y1.val[0])); + int16x8_t b1_even = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y1.val[0])); + int16x8_t g1_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), + y1.val[1])); + int16x8_t r1_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), + y1.val[1])); + int16x8_t b1_odd = + vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), + y1.val[1])); + /* Convert each component to unsigned and narrow, clamping to [0-255]. + * Re-interleave the "even" and "odd" component values. + */ + uint8x8x2_t r0 = vzip_u8(vqmovun_s16(r0_even), vqmovun_s16(r0_odd)); + uint8x8x2_t r1 = vzip_u8(vqmovun_s16(r1_even), vqmovun_s16(r1_odd)); + uint8x8x2_t g0 = vzip_u8(vqmovun_s16(g0_even), vqmovun_s16(g0_odd)); + uint8x8x2_t g1 = vzip_u8(vqmovun_s16(g1_even), vqmovun_s16(g1_odd)); + uint8x8x2_t b0 = vzip_u8(vqmovun_s16(b0_even), vqmovun_s16(b0_odd)); + uint8x8x2_t b1 = vzip_u8(vqmovun_s16(b1_even), vqmovun_s16(b1_odd)); + +#ifdef RGB_ALPHA + uint8x8x4_t rgba0_h, rgba1_h; + rgba0_h.val[RGB_RED] = r0.val[1]; + rgba1_h.val[RGB_RED] = r1.val[1]; + rgba0_h.val[RGB_GREEN] = g0.val[1]; + rgba1_h.val[RGB_GREEN] = g1.val[1]; + rgba0_h.val[RGB_BLUE] = b0.val[1]; + rgba1_h.val[RGB_BLUE] = b1.val[1]; + /* Set alpha channel to opaque (0xFF). */ + rgba0_h.val[RGB_ALPHA] = vdup_n_u8(0xFF); + rgba1_h.val[RGB_ALPHA] = vdup_n_u8(0xFF); + + uint8x8x4_t rgba0_l, rgba1_l; + rgba0_l.val[RGB_RED] = r0.val[0]; + rgba1_l.val[RGB_RED] = r1.val[0]; + rgba0_l.val[RGB_GREEN] = g0.val[0]; + rgba1_l.val[RGB_GREEN] = g1.val[0]; + rgba0_l.val[RGB_BLUE] = b0.val[0]; + rgba1_l.val[RGB_BLUE] = b1.val[0]; + /* Set alpha channel to opaque (0xFF). */ + rgba0_l.val[RGB_ALPHA] = vdup_n_u8(0xFF); + rgba1_l.val[RGB_ALPHA] = vdup_n_u8(0xFF); + /* Store RGBA pixel data to memory. */ + switch (cols_remaining) { + case 15: + vst4_lane_u8(outptr0 + 14 * RGB_PIXELSIZE, rgba0_h, 6); + vst4_lane_u8(outptr1 + 14 * RGB_PIXELSIZE, rgba1_h, 6); + case 14: + vst4_lane_u8(outptr0 + 13 * RGB_PIXELSIZE, rgba0_h, 5); + vst4_lane_u8(outptr1 + 13 * RGB_PIXELSIZE, rgba1_h, 5); + case 13: + vst4_lane_u8(outptr0 + 12 * RGB_PIXELSIZE, rgba0_h, 4); + vst4_lane_u8(outptr1 + 12 * RGB_PIXELSIZE, rgba1_h, 4); + case 12: + vst4_lane_u8(outptr0 + 11 * RGB_PIXELSIZE, rgba0_h, 3); + vst4_lane_u8(outptr1 + 11 * RGB_PIXELSIZE, rgba1_h, 3); + case 11: + vst4_lane_u8(outptr0 + 10 * RGB_PIXELSIZE, rgba0_h, 2); + vst4_lane_u8(outptr1 + 10 * RGB_PIXELSIZE, rgba1_h, 2); + case 10: + vst4_lane_u8(outptr0 + 9 * RGB_PIXELSIZE, rgba0_h, 1); + vst4_lane_u8(outptr1 + 9 * RGB_PIXELSIZE, rgba1_h, 1); + case 9: + vst4_lane_u8(outptr0 + 8 * RGB_PIXELSIZE, rgba0_h, 0); + vst4_lane_u8(outptr1 + 8 * RGB_PIXELSIZE, rgba1_h, 0); + case 8: + vst4_u8(outptr0, rgba0_l); + vst4_u8(outptr1, rgba1_l); + break; + case 7: + vst4_lane_u8(outptr0 + 6 * RGB_PIXELSIZE, rgba0_l, 6); + vst4_lane_u8(outptr1 + 6 * RGB_PIXELSIZE, rgba1_l, 6); + case 6: + vst4_lane_u8(outptr0 + 5 * RGB_PIXELSIZE, rgba0_l, 5); + vst4_lane_u8(outptr1 + 5 * RGB_PIXELSIZE, rgba1_l, 5); + case 5: + vst4_lane_u8(outptr0 + 4 * RGB_PIXELSIZE, rgba0_l, 4); + vst4_lane_u8(outptr1 + 4 * RGB_PIXELSIZE, rgba1_l, 4); + case 4: + vst4_lane_u8(outptr0 + 3 * RGB_PIXELSIZE, rgba0_l, 3); + vst4_lane_u8(outptr1 + 3 * RGB_PIXELSIZE, rgba1_l, 3); + case 3: + vst4_lane_u8(outptr0 + 2 * RGB_PIXELSIZE, rgba0_l, 2); + vst4_lane_u8(outptr1 + 2 * RGB_PIXELSIZE, rgba1_l, 2); + case 2: + vst4_lane_u8(outptr0 + 1 * RGB_PIXELSIZE, rgba0_l, 1); + vst4_lane_u8(outptr1 + 1 * RGB_PIXELSIZE, rgba1_l, 1); + case 1: + vst4_lane_u8(outptr0, rgba0_l, 0); + vst4_lane_u8(outptr1, rgba1_l, 0); + default: + break; + } +#else + uint8x8x3_t rgb0_h, rgb1_h; + rgb0_h.val[RGB_RED] = r0.val[1]; + rgb1_h.val[RGB_RED] = r1.val[1]; + rgb0_h.val[RGB_GREEN] = g0.val[1]; + rgb1_h.val[RGB_GREEN] = g1.val[1]; + rgb0_h.val[RGB_BLUE] = b0.val[1]; + rgb1_h.val[RGB_BLUE] = b1.val[1]; + + uint8x8x3_t rgb0_l, rgb1_l; + rgb0_l.val[RGB_RED] = r0.val[0]; + rgb1_l.val[RGB_RED] = r1.val[0]; + rgb0_l.val[RGB_GREEN] = g0.val[0]; + rgb1_l.val[RGB_GREEN] = g1.val[0]; + rgb0_l.val[RGB_BLUE] = b0.val[0]; + rgb1_l.val[RGB_BLUE] = b1.val[0]; + /* Store RGB pixel data to memory. */ + switch (cols_remaining) { + case 15: + vst3_lane_u8(outptr0 + 14 * RGB_PIXELSIZE, rgb0_h, 6); + vst3_lane_u8(outptr1 + 14 * RGB_PIXELSIZE, rgb1_h, 6); + case 14: + vst3_lane_u8(outptr0 + 13 * RGB_PIXELSIZE, rgb0_h, 5); + vst3_lane_u8(outptr1 + 13 * RGB_PIXELSIZE, rgb1_h, 5); + case 13: + vst3_lane_u8(outptr0 + 12 * RGB_PIXELSIZE, rgb0_h, 4); + vst3_lane_u8(outptr1 + 12 * RGB_PIXELSIZE, rgb1_h, 4); + case 12: + vst3_lane_u8(outptr0 + 11 * RGB_PIXELSIZE, rgb0_h, 3); + vst3_lane_u8(outptr1 + 11 * RGB_PIXELSIZE, rgb1_h, 3); + case 11: + vst3_lane_u8(outptr0 + 10 * RGB_PIXELSIZE, rgb0_h, 2); + vst3_lane_u8(outptr1 + 10 * RGB_PIXELSIZE, rgb1_h, 2); + case 10: + vst3_lane_u8(outptr0 + 9 * RGB_PIXELSIZE, rgb0_h, 1); + vst3_lane_u8(outptr1 + 9 * RGB_PIXELSIZE, rgb1_h, 1); + case 9: + vst3_lane_u8(outptr0 + 8 * RGB_PIXELSIZE, rgb0_h, 0); + vst3_lane_u8(outptr1 + 8 * RGB_PIXELSIZE, rgb1_h, 0); + case 8: + vst3_u8(outptr0, rgb0_l); + vst3_u8(outptr1, rgb1_l); + break; + case 7: + vst3_lane_u8(outptr0 + 6 * RGB_PIXELSIZE, rgb0_l, 6); + vst3_lane_u8(outptr1 + 6 * RGB_PIXELSIZE, rgb1_l, 6); + case 6: + vst3_lane_u8(outptr0 + 5 * RGB_PIXELSIZE, rgb0_l, 5); + vst3_lane_u8(outptr1 + 5 * RGB_PIXELSIZE, rgb1_l, 5); + case 5: + vst3_lane_u8(outptr0 + 4 * RGB_PIXELSIZE, rgb0_l, 4); + vst3_lane_u8(outptr1 + 4 * RGB_PIXELSIZE, rgb1_l, 4); + case 4: + vst3_lane_u8(outptr0 + 3 * RGB_PIXELSIZE, rgb0_l, 3); + vst3_lane_u8(outptr1 + 3 * RGB_PIXELSIZE, rgb1_l, 3); + case 3: + vst3_lane_u8(outptr0 + 2 * RGB_PIXELSIZE, rgb0_l, 2); + vst3_lane_u8(outptr1 + 2 * RGB_PIXELSIZE, rgb1_l, 2); + case 2: + vst3_lane_u8(outptr0 + 1 * RGB_PIXELSIZE, rgb0_l, 1); + vst3_lane_u8(outptr1 + 1 * RGB_PIXELSIZE, rgb1_l, 1); + case 1: + vst3_lane_u8(outptr0, rgb0_l, 0); + vst3_lane_u8(outptr1, rgb1_l, 0); + default: + break; + } +#endif + } +} diff --git a/simd/jsimd.h b/simd/jsimd.h index 053ea3c39..ccc9a1047 100644 --- a/simd/jsimd.h +++ b/simd/jsimd.h @@ -824,6 +824,50 @@ EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_avx2 (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); + +EXTERN(void) jsimd_h2v2_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); +EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_neon + (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf); + EXTERN(void) jsimd_h2v1_merged_upsample_dspr2 (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf, JSAMPLE *range);
0
fd6330292501983ac75fe4162275794b18445bd9
https://github.com/LibRaw/LibRaw/commit/fd6330292501983ac75fe4162275794b18445bd9
Secunia 81800#1: samsumg_load_raw Secunia 81800#2: find_green Secunia 81800#3: rollei_load_raw remove_trailing_spaces: isspace() does not works right with signed non-latin chars Secunia 81800#5/6: nikon_coolscan_load_raw Secunia 81800#4: rollei_load_raw
diff --git a/dcraw/dcraw.c b/dcraw/dcraw.c index 1c6bf662..e2b9c7d4 100644 --- a/dcraw/dcraw.c +++ b/dcraw/dcraw.c @@ -251,6 +251,7 @@ static float fMAX(float a, float b) 3 G R G R G R 3 B G B G B G 3 R G R G R G 3 G B G B G B */ +#define RAWINDEX(row, col) ((row)*raw_width + (col)) #define RAW(row,col) \ raw_image[(row)*raw_width+(col)] //@end DEFINES @@ -1511,9 +1512,14 @@ void CLASS pentax_load_raw() void CLASS nikon_coolscan_load_raw() { - int bufsize = width*3*tiff_bps/8; - if(tiff_bps <= 8) - gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,255); + if(!image) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + int bypp = tiff_bps <= 8 ? 1 : 2; + int bufsize = width * 3 * bypp; + + if (tiff_bps <= 8) + gamma_curve(1.0 / imgdata.params.coolscan_nef_gamma, 0., 1, 255); else gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,65535); fseek (ifp, data_offset, SEEK_SET); @@ -1794,7 +1800,12 @@ void CLASS rollei_thumb() void CLASS rollei_load_raw() { uchar pixel[10]; - unsigned iten=0, isix, i, buffer=0, todo[16]; + unsigned iten = 0, isix, i, buffer = 0, todo[16]; +#ifdef LIBRAW_LIBRARY_BUILD + if(raw_width > 32767 || raw_height > 32767) + throw LIBRAW_EXCEPTION_IO_BADFILE; +#endif + unsigned maxpixel = raw_width*(raw_height+7); isix = raw_width * raw_height * 5 / 8; while (fread (pixel, 1, 10, ifp) == 10) { @@ -1810,8 +1821,11 @@ void CLASS rollei_load_raw() todo[i] = isix++; todo[i+1] = buffer >> (14-i)*5; } - for (i=0; i < 16; i+=2) - raw_image[todo[i]] = (todo[i+1] & 0x3ff); + for (i = 0; i < 16; i += 2) + if(todo[i] < maxpixel) + raw_image[todo[i]] = (todo[i + 1] & 0x3ff); + else + derror(); } maximum = 0x3ff; } @@ -3857,6 +3871,11 @@ void CLASS sony_arw2_load_raw() void CLASS samsung_load_raw() { int row, col, c, i, dir, op[4], len[4]; +#ifdef LIBRAW_LIBRARY_BUILD + if(raw_width> 32768 || raw_height > 32768) // definitely too much for old samsung + throw LIBRAW_EXCEPTION_IO_BADFILE; +#endif + unsigned maxpixels = raw_width*(raw_height+7); order = 0x4949; for (row=0; row < raw_height; row++) { @@ -3875,11 +3894,17 @@ void CLASS samsung_load_raw() case 2: len[c]--; break; case 1: len[c]++; } - for (c=0; c < 16; c+=2) { - i = len[((c & 1) << 1) | (c >> 3)]; - RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) + - (dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128); - if (c == 14) c = -1; + for (c = 0; c < 16; c += 2) + { + i = len[((c & 1) << 1) | (c >> 3)]; + unsigned idest = RAWINDEX(row, col + c); + unsigned isrc = (dir ? RAWINDEX(row + (~c | -2), col + c) : col ? RAWINDEX(row, col + (c | -2)) : 0); + if(idest < maxpixels && isrc < maxpixels) // less than zero is handled by unsigned conversion + RAW(row, col + c) = ((signed)ph1_bits(i) << (32 - i) >> (32 - i)) + (dir ? RAW(row + (~c | -2), col + c) : col ? RAW(row, col + (c | -2)) : 128); + else + derror(); + if (c == 14) + c = -1; } } } @@ -11081,37 +11106,68 @@ void CLASS parse_exif (int base) if (((make[0] == '\0') && (!strncmp(model, "ov5647",6))) || ((!strncmp(make, "RaspberryPi",11)) && (!strncmp(model, "RP_OV5647",9))) || ((!strncmp(make, "RaspberryPi",11)) && (!strncmp(model, "RP_imx219",9)))) { - char mn_text[512]; - char* pos; - char ccms[512]; - ushort l; - float num; - - fgets(mn_text, len, ifp); - pos = strstr(mn_text, "gain_r="); - if (pos) cam_mul[0] = atof(pos+7); - pos = strstr(mn_text, "gain_b="); - if (pos) cam_mul[2] = atof(pos+7); - if ((cam_mul[0] > 0.001f) && (cam_mul[2] > 0.001f)) cam_mul[1] = cam_mul[3] = 1.0f; - else cam_mul[0] = cam_mul[2] = 0.0f; - - pos = strstr(mn_text, "ccm=") + 4; - l = strstr(pos, " ") - pos; - memcpy (ccms, pos, l); - ccms[l] = '\0'; - - pos = strtok (ccms, ","); - for (l=0; l<4; l++) { - num = 0.0; - for (c=0; c<3; c++) { - imgdata.color.ccm[l][c] = (float)atoi(pos); - num += imgdata.color.ccm[l][c]; - pos = strtok (NULL, ","); - } - if (num > 0.01) FORC3 imgdata.color.ccm[l][c] = imgdata.color.ccm[l][c] / num; - } + char mn_text[512]; + char *pos; + char ccms[512]; + ushort l; + float num; + + fgets(mn_text, MIN(len,511), ifp); + mn_text[511] = 0; + + pos = strstr(mn_text, "gain_r="); + if (pos) + cam_mul[0] = atof(pos + 7); + pos = strstr(mn_text, "gain_b="); + if (pos) + cam_mul[2] = atof(pos + 7); + if ((cam_mul[0] > 0.001f) && (cam_mul[2] > 0.001f)) + cam_mul[1] = cam_mul[3] = 1.0f; + else + cam_mul[0] = cam_mul[2] = 0.0f; + + pos = strstr(mn_text, "ccm="); + if(pos) + { + pos +=4; + char *pos2 = strstr(pos, " "); + if(pos2) + { + l = pos2 - pos; + memcpy(ccms, pos, l); + ccms[l] = '\0'; +#if defined WIN32 || defined(__MINGW32__) + // Win32 strtok is already thread-safe + pos = strtok(ccms, ","); +#else + char *last=0; + pos = strtok_r(ccms, ",",&last); +#endif + if(pos) + { + for (l = 0; l < 4; l++) + { + num = 0.0; + for (c = 0; c < 3; c++) + { + imgdata.color.ccm[l][c] = (float)atoi(pos); + num += imgdata.color.ccm[l][c]; +#if defined WIN32 || defined(__MINGW32__) + pos = strtok(NULL, ","); +#else + pos = strtok_r(NULL, ",",&last); +#endif + if(!pos) goto end; // broken + } + if (num > 0.01) + FORC3 imgdata.color.ccm[l][c] = imgdata.color.ccm[l][c] / num; + } + } + } } - else + end:; + } + else #endif parse_makernote (base, 0); break; @@ -15077,7 +15133,8 @@ float CLASS find_green (int bps, int bite, int off0, int off1) UINT64 bitbuf=0; int vbits, col, i, c; ushort img[2][2064]; - double sum[]={0,0}; + double sum[] = {0, 0}; + if(width > 2064) return 0.f; // too wide FORC(2) { fseek (ifp, c ? off1:off0, SEEK_SET); @@ -15100,14 +15157,16 @@ float CLASS find_green (int bps, int bite, int off0, int off1) #ifdef LIBRAW_LIBRARY_BUILD static void remove_trailing_spaces(char *string, size_t len) { - if(len<1) return; // not needed, b/c sizeof of make/model is 64 - string[len-1]=0; - if(len<3) return; // also not needed - len = strnlen(string,len-1); - for(int i=len-1; i>=0; i--) + if (len < 1) + return; // not needed, b/c sizeof of make/model is 64 + string[len - 1] = 0; + if (len < 3) + return; // also not needed + len = strnlen(string, len - 1); + for (int i = len - 1; i >= 0; i--) { - if(isspace(string[i])) - string[i]=0; + if (isspace((unsigned char)string[i])) + string[i] = 0; else break; } diff --git a/internal/dcraw_common.cpp b/internal/dcraw_common.cpp index cfb82a27..b430d3e5 100644 --- a/internal/dcraw_common.cpp +++ b/internal/dcraw_common.cpp @@ -1228,9 +1228,14 @@ void CLASS pentax_load_raw() void CLASS nikon_coolscan_load_raw() { - int bufsize = width*3*tiff_bps/8; - if(tiff_bps <= 8) - gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,255); + if(!image) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + int bypp = tiff_bps <= 8 ? 1 : 2; + int bufsize = width * 3 * bypp; + + if (tiff_bps <= 8) + gamma_curve(1.0 / imgdata.params.coolscan_nef_gamma, 0., 1, 255); else gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,65535); fseek (ifp, data_offset, SEEK_SET); @@ -1506,7 +1511,12 @@ void CLASS rollei_thumb() void CLASS rollei_load_raw() { uchar pixel[10]; - unsigned iten=0, isix, i, buffer=0, todo[16]; + unsigned iten = 0, isix, i, buffer = 0, todo[16]; +#ifdef LIBRAW_LIBRARY_BUILD + if(raw_width > 32767 || raw_height > 32767) + throw LIBRAW_EXCEPTION_IO_BADFILE; +#endif + unsigned maxpixel = raw_width*(raw_height+7); isix = raw_width * raw_height * 5 / 8; while (fread (pixel, 1, 10, ifp) == 10) { @@ -1522,8 +1532,11 @@ void CLASS rollei_load_raw() todo[i] = isix++; todo[i+1] = buffer >> (14-i)*5; } - for (i=0; i < 16; i+=2) - raw_image[todo[i]] = (todo[i+1] & 0x3ff); + for (i = 0; i < 16; i += 2) + if(todo[i] < maxpixel) + raw_image[todo[i]] = (todo[i + 1] & 0x3ff); + else + derror(); } maximum = 0x3ff; } @@ -3569,6 +3582,11 @@ void CLASS sony_arw2_load_raw() void CLASS samsung_load_raw() { int row, col, c, i, dir, op[4], len[4]; +#ifdef LIBRAW_LIBRARY_BUILD + if(raw_width> 32768 || raw_height > 32768) // definitely too much for old samsung + throw LIBRAW_EXCEPTION_IO_BADFILE; +#endif + unsigned maxpixels = raw_width*(raw_height+7); order = 0x4949; for (row=0; row < raw_height; row++) { @@ -3587,11 +3605,17 @@ void CLASS samsung_load_raw() case 2: len[c]--; break; case 1: len[c]++; } - for (c=0; c < 16; c+=2) { - i = len[((c & 1) << 1) | (c >> 3)]; - RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) + - (dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128); - if (c == 14) c = -1; + for (c = 0; c < 16; c += 2) + { + i = len[((c & 1) << 1) | (c >> 3)]; + unsigned idest = RAWINDEX(row, col + c); + unsigned isrc = (dir ? RAWINDEX(row + (~c | -2), col + c) : col ? RAWINDEX(row, col + (c | -2)) : 0); + if(idest < maxpixels && isrc < maxpixels) // less than zero is handled by unsigned conversion + RAW(row, col + c) = ((signed)ph1_bits(i) << (32 - i) >> (32 - i)) + (dir ? RAW(row + (~c | -2), col + c) : col ? RAW(row, col + (c | -2)) : 128); + else + derror(); + if (c == 14) + c = -1; } } } @@ -9890,37 +9914,68 @@ void CLASS parse_exif (int base) if (((make[0] == '\0') && (!strncmp(model, "ov5647",6))) || ((!strncmp(make, "RaspberryPi",11)) && (!strncmp(model, "RP_OV5647",9))) || ((!strncmp(make, "RaspberryPi",11)) && (!strncmp(model, "RP_imx219",9)))) { - char mn_text[512]; - char* pos; - char ccms[512]; - ushort l; - float num; - - fgets(mn_text, len, ifp); - pos = strstr(mn_text, "gain_r="); - if (pos) cam_mul[0] = atof(pos+7); - pos = strstr(mn_text, "gain_b="); - if (pos) cam_mul[2] = atof(pos+7); - if ((cam_mul[0] > 0.001f) && (cam_mul[2] > 0.001f)) cam_mul[1] = cam_mul[3] = 1.0f; - else cam_mul[0] = cam_mul[2] = 0.0f; - - pos = strstr(mn_text, "ccm=") + 4; - l = strstr(pos, " ") - pos; - memcpy (ccms, pos, l); - ccms[l] = '\0'; - - pos = strtok (ccms, ","); - for (l=0; l<4; l++) { - num = 0.0; - for (c=0; c<3; c++) { - imgdata.color.ccm[l][c] = (float)atoi(pos); - num += imgdata.color.ccm[l][c]; - pos = strtok (NULL, ","); - } - if (num > 0.01) FORC3 imgdata.color.ccm[l][c] = imgdata.color.ccm[l][c] / num; - } + char mn_text[512]; + char *pos; + char ccms[512]; + ushort l; + float num; + + fgets(mn_text, MIN(len,511), ifp); + mn_text[511] = 0; + + pos = strstr(mn_text, "gain_r="); + if (pos) + cam_mul[0] = atof(pos + 7); + pos = strstr(mn_text, "gain_b="); + if (pos) + cam_mul[2] = atof(pos + 7); + if ((cam_mul[0] > 0.001f) && (cam_mul[2] > 0.001f)) + cam_mul[1] = cam_mul[3] = 1.0f; + else + cam_mul[0] = cam_mul[2] = 0.0f; + + pos = strstr(mn_text, "ccm="); + if(pos) + { + pos +=4; + char *pos2 = strstr(pos, " "); + if(pos2) + { + l = pos2 - pos; + memcpy(ccms, pos, l); + ccms[l] = '\0'; +#if defined WIN32 || defined(__MINGW32__) + // Win32 strtok is already thread-safe + pos = strtok(ccms, ","); +#else + char *last=0; + pos = strtok_r(ccms, ",",&last); +#endif + if(pos) + { + for (l = 0; l < 4; l++) + { + num = 0.0; + for (c = 0; c < 3; c++) + { + imgdata.color.ccm[l][c] = (float)atoi(pos); + num += imgdata.color.ccm[l][c]; +#if defined WIN32 || defined(__MINGW32__) + pos = strtok(NULL, ","); +#else + pos = strtok_r(NULL, ",",&last); +#endif + if(!pos) goto end; // broken + } + if (num > 0.01) + FORC3 imgdata.color.ccm[l][c] = imgdata.color.ccm[l][c] / num; + } + } + } } - else + end:; + } + else #endif parse_makernote (base, 0); break; @@ -13739,7 +13794,8 @@ float CLASS find_green (int bps, int bite, int off0, int off1) UINT64 bitbuf=0; int vbits, col, i, c; ushort img[2][2064]; - double sum[]={0,0}; + double sum[] = {0, 0}; + if(width > 2064) return 0.f; // too wide FORC(2) { fseek (ifp, c ? off1:off0, SEEK_SET); @@ -13762,14 +13818,16 @@ float CLASS find_green (int bps, int bite, int off0, int off1) #ifdef LIBRAW_LIBRARY_BUILD static void remove_trailing_spaces(char *string, size_t len) { - if(len<1) return; // not needed, b/c sizeof of make/model is 64 - string[len-1]=0; - if(len<3) return; // also not needed - len = strnlen(string,len-1); - for(int i=len-1; i>=0; i--) + if (len < 1) + return; // not needed, b/c sizeof of make/model is 64 + string[len - 1] = 0; + if (len < 3) + return; // also not needed + len = strnlen(string, len - 1); + for (int i = len - 1; i >= 0; i--) { - if(isspace(string[i])) - string[i]=0; + if (isspace((unsigned char)string[i])) + string[i] = 0; else break; } diff --git a/internal/defines.h b/internal/defines.h index b84e1d28..06e171ec 100644 --- a/internal/defines.h +++ b/internal/defines.h @@ -153,6 +153,7 @@ static float fMAX(float a, float b) 3 G R G R G R 3 B G B G B G 3 R G R G R G 3 G B G B G B */ +#define RAWINDEX(row, col) ((row)*raw_width + (col)) #define RAW(row,col) \ raw_image[(row)*raw_width+(col)] #define BAYER(row,col) \
1
aff4d0aefcdb99726fd739abf3b9bb96df97b0f
https://github.com/spring-projects/spring-amqp/commit/aff4d0aefcdb99726fd739abf3b9bb96df97b0f
AMQP-830 Enable Hostname Verification by default JIRA: https://jira.spring.io/browse/AMQP-830
diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitConnectionFactoryBean.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitConnectionFactoryBean.java index b4f18a41e9..2e59cd2843 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitConnectionFactoryBean.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitConnectionFactoryBean.java @@ -16,11 +16,11 @@ package org.springframework.amqp.rabbit.connection; +import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; import java.security.KeyManagementException; import java.security.KeyStore; -import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Arrays; @@ -28,8 +28,10 @@ import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicReference; import javax.net.SocketFactory; +import javax.net.ssl.HostnameVerifier; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; @@ -42,6 +44,10 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; +import org.springframework.util.ReflectionUtils.MethodCallback; +import org.springframework.util.ReflectionUtils.MethodFilter; import org.springframework.util.StringUtils; import com.rabbitmq.client.ConnectionFactory; @@ -75,6 +81,37 @@ */ public class RabbitConnectionFactoryBean extends AbstractFactoryBean<ConnectionFactory> { + public static final Method enableHostnameVerificationNoArgMethod; + + public static final Method enableHostnameVerificationOneArgMethod; + + static { + final AtomicReference<Method> method1 = new AtomicReference<Method>(); + final AtomicReference<Method> method2 = new AtomicReference<Method>(); + ReflectionUtils.doWithMethods(ConnectionFactory.class, new MethodCallback() { + + @Override + public void doWith(Method m) throws IllegalArgumentException, IllegalAccessException { + if (m.getParameterTypes().length == 0) { + method1.set(m); + } + else if (m.getParameterTypes().length == 1 && m.getParameterTypes()[0].equals(HostnameVerifier.class)) { + method2.set(m); + } + } + + }, new MethodFilter() { + + @Override + public boolean matches(Method m) { + return m.getName().equals("enableHostnameVerification"); + } + + }); + enableHostnameVerificationNoArgMethod = method1.get(); + enableHostnameVerificationOneArgMethod = method2.get(); + } + private final Log logger = LogFactory.getLog(getClass()); private static final String KEY_STORE = "keyStore"; @@ -103,30 +140,34 @@ private Resource sslPropertiesLocation; - private volatile String keyStore; + private String keyStore; - private volatile String trustStore; + private String trustStore; - private volatile Resource keyStoreResource; + private Resource keyStoreResource; - private volatile Resource trustStoreResource; + private Resource trustStoreResource; - private volatile String keyStorePassphrase; + private String keyStorePassphrase; - private volatile String trustStorePassphrase; + private String trustStorePassphrase; - private volatile String keyStoreType; + private String keyStoreType; - private volatile String trustStoreType; + private String trustStoreType; - private volatile String sslAlgorithm = TLS_V1_1; + private String sslAlgorithm = TLS_V1_1; - private volatile boolean sslAlgorithmSet; + private boolean sslAlgorithmSet; - private volatile SecureRandom secureRandom; + private SecureRandom secureRandom; private boolean skipServerCertificateValidation = true; + private boolean enableHostnameVerification; + + private HostnameVerifier hostnameVerifier; + public RabbitConnectionFactoryBean() { this.connectionFactory.setAutomaticRecoveryEnabled(false); } @@ -592,6 +633,46 @@ public void setTopologyRecoveryEnabled(boolean topologyRecoveryEnabled) { this.connectionFactory.setTopologyRecoveryEnabled(topologyRecoveryEnabled); } + /** + * Enable server hostname verification for TLS connections. + * <p> + * This enables hostname verification regardless of the IO mode used (blocking or + * non-blocking IO). + * <p> + * If <strong>using Java 7 or more</strong>, the hostname verification will be + * performed by Java, as part of the TLS handshake. + * <p> + * If <strong>using Java 6</strong>, the hostname verification will be handled after + * the TLS handshake, using the {@link HostnameVerifier} from the Commons HttpClient + * project. This requires to add Commons HttpClient and its dependencies to the + * classpath. To use a custom {@link HostnameVerifier}, use + * {@link #setHostnameVerifier(HostnameVerifier)}. Requires + * amqp-client 4.8.0 or later. + * @param enable true to enable. + * @since 1.7.10 + * @see #setHostnameVerifier(HostnameVerifier) + */ + public void setEnableHostnameVerification(boolean enable) { + Assert.notNull(enableHostnameVerificationNoArgMethod, + "Host name verification requires amqp-client 4.8.0 or later"); + this.enableHostnameVerification = enable; + } + + /** + * Set a custom {@link HostnameVerifier} for use with + * {@link #setEnableHostnameVerification(boolean)}. + * @param hostnameVerifier the verifier. + * @see #setEnableHostnameVerification(boolean) + * @deprecated only used with Java 6 + */ + @Deprecated + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + Assert.notNull(enableHostnameVerificationOneArgMethod, + "Host name verification requires amqp-client 4.8.0 or later, " + + "when using 5.8.0 or later, a custom verifier is not required"); + this.hostnameVerifier = hostnameVerifier; + } + @Override public Class<?> getObjectType() { return ConnectionFactory.class; @@ -674,6 +755,7 @@ protected void setUpSSL() throws Exception { SSLContext context = createSSLContext(); context.init(keyManagers, trustManagers, this.secureRandom); this.connectionFactory.useSslProtocol(context); + checkHostVerification(); } } @@ -689,14 +771,25 @@ protected SSLContext createSSLContext() throws NoSuchAlgorithmException { } - private void useDefaultTrustStoreMechanism() - throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { + private void useDefaultTrustStoreMechanism() throws Exception { SSLContext sslContext = SSLContext.getInstance(this.sslAlgorithm); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init((KeyStore) null); sslContext.init(null, trustManagerFactory.getTrustManagers(), null); this.connectionFactory.useSslProtocol(sslContext); + checkHostVerification(); + } + + private void checkHostVerification() throws Exception { + if (this.enableHostnameVerification) { + if (this.hostnameVerifier == null) { + enableHostnameVerificationNoArgMethod.invoke(this.connectionFactory); + } + else { + enableHostnameVerificationOneArgMethod.invoke(this.connectionFactory, this.hostnameVerifier); + } + } } } diff --git a/src/reference/asciidoc/whats-new.adoc b/src/reference/asciidoc/whats-new.adoc index 693fd728cf..ca0da79aac 100644 --- a/src/reference/asciidoc/whats-new.adoc +++ b/src/reference/asciidoc/whats-new.adoc @@ -62,6 +62,12 @@ See <<connections>> for more information. Message requeue on transaction rollback can now be configured to be consistent, regardless of whether or not a transaction manager is configured. See <<transaction-rollback>> for more information. +===== Connection Factory Bean Changes + +The `RabbitConnectionFactoryBean` now provides an `enabaleHostnameVerification` property; set it to `true` to enable host name verification. +Also `setHostnameVerifier` is provided for when using Java 6; see the connection factory javadocs for more information. +Host name verification requires overriding the `amqp-client` to 4.8.0 or later. + ==== Earlier Releases See <<previous-whats-new>> for changes in previous versions.
1
d0c8aa312dcab75c265ed6123f8afe0d7c8e91db
https://github.com/rpm-software-management/libcomps/commit/d0c8aa312dcab75c265ed6123f8afe0d7c8e91db
Release 0.1.12
diff --git a/libcomps.spec b/libcomps.spec index 3f710fa..6bc27eb 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -13,7 +13,7 @@ %endif Name: libcomps -Version: 0.1.11 +Version: 0.1.12 Release: 1%{?dist} Summary: Comps XML file manipulation library diff --git a/libcomps/version.cmake b/libcomps/version.cmake index 8d14d31..a8842fb 100644 --- a/libcomps/version.cmake +++ b/libcomps/version.cmake @@ -1,5 +1,5 @@ set (libcomps_VERSION_MAJOR 0) set (libcomps_VERSION_MINOR 1) -set (libcomps_VERSION_PATCH 11) +set (libcomps_VERSION_PATCH 12) set (libcomps_RELEASE 1) diff --git a/rel-eng/packages/libcomps b/rel-eng/packages/libcomps index 154924b..2be6839 100644 --- a/rel-eng/packages/libcomps +++ b/rel-eng/packages/libcomps @@ -1 +1 @@ -0.1.11-1 ./ +0.1.12-1 ./ diff --git a/version.json b/version.json index 1866c9e..72de476 100644 --- a/version.json +++ b/version.json @@ -2,5 +2,5 @@ "libcomps_VERSION_MAJOR": 0, "libcomps_RELEASE": 1, "libcomps_VERSION_MINOR": 1, - "libcomps_VERSION_PATCH": 11 + "libcomps_VERSION_PATCH": 12 }
0
953d0a8ba9827aee870f00afb3ca38721dea239c
https://github.com/laravel/framework/commit/953d0a8ba9827aee870f00afb3ca38721dea239c
Merge pull request #12765 from GrahamForks/5.1-rand [5.1] Ensure openssl's vulnerable random generation is not used
diff --git a/composer.json b/composer.json index 82decea427ba..01784a15b0a0 100755 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "monolog/monolog": "~1.11", "mtdowling/cron-expression": "~1.0", "nesbot/carbon": "~1.19", - "paragonie/random_compat": "~1.1", + "paragonie/random_compat": "~1.3", "psy/psysh": "0.7.*", "swiftmailer/swiftmailer": "~5.1", "symfony/console": "2.7.*", diff --git a/src/Illuminate/Encryption/composer.json b/src/Illuminate/Encryption/composer.json index 1db654772e7d..47328eaaf93b 100755 --- a/src/Illuminate/Encryption/composer.json +++ b/src/Illuminate/Encryption/composer.json @@ -18,7 +18,8 @@ "ext-mbstring": "*", "ext-openssl": "*", "illuminate/contracts": "5.1.*", - "illuminate/support": "5.1.*" + "illuminate/support": "5.1.*", + "paragonie/random_compat": "~1.3" }, "autoload": { "psr-4": { @@ -30,8 +31,5 @@ "dev-master": "5.1-dev" } }, - "suggest": { - "paragonie/random_compat": "Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (~1.1)." - }, "minimum-stability": "dev" } diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 6e5b8547c4df..6da99ddb113c 100755 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -2,7 +2,6 @@ namespace Illuminate\Support; -use RuntimeException; use Stringy\StaticStringy; use Illuminate\Support\Traits\Macroable; @@ -217,8 +216,6 @@ public static function plural($value, $count = 2) * * @param int $length * @return string - * - * @throws \RuntimeException */ public static function random($length = 16) { @@ -240,24 +237,10 @@ public static function random($length = 16) * * @param int $length * @return string - * - * @throws \RuntimeException */ public static function randomBytes($length = 16) { - if (PHP_MAJOR_VERSION >= 7 || defined('RANDOM_COMPAT_READ_BUFFER')) { - $bytes = random_bytes($length); - } elseif (function_exists('openssl_random_pseudo_bytes')) { - $bytes = openssl_random_pseudo_bytes($length, $strong); - - if ($bytes === false || $strong === false) { - throw new RuntimeException('Unable to generate random string.'); - } - } else { - throw new RuntimeException('OpenSSL extension or paragonie/random_compat is required for PHP 5 users.'); - } - - return $bytes; + return random_bytes($length); } /** diff --git a/src/Illuminate/Support/composer.json b/src/Illuminate/Support/composer.json index bfef52588329..3146b21a869e 100755 --- a/src/Illuminate/Support/composer.json +++ b/src/Illuminate/Support/composer.json @@ -18,7 +18,8 @@ "ext-mbstring": "*", "illuminate/contracts": "5.1.*", "doctrine/inflector": "~1.0", - "danielstjules/stringy": "~1.8" + "danielstjules/stringy": "~1.8", + "paragonie/random_compat": "~1.3" }, "autoload": { "psr-4": { @@ -35,7 +36,6 @@ }, "suggest": { "jeremeamia/superclosure": "Required to be able to serialize closures (~2.0).", - "paragonie/random_compat": "Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (~1.1).", "symfony/var-dumper": "Improves the dd function (2.7.*)." }, "minimum-stability": "dev"
1
68601933eb1c192a244d705f6e8d1e2b672520e6
https://github.com/lingej/pnp4nagios/commit/68601933eb1c192a244d705f6e8d1e2b672520e6
rrd.php: added helper 'colbright' to adjust the brightness of predefined colors.
diff --git a/share/pnp/application/helpers/rrd.php b/share/pnp/application/helpers/rrd.php index 2da22f4..81bb257 100644 --- a/share/pnp/application/helpers/rrd.php +++ b/share/pnp/application/helpers/rrd.php @@ -444,6 +444,35 @@ public static function darkteint(){ return $line; } + # http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php + public static function colbright($hex, $steps) { + if($hex === FALSE){ + throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'hex' is missing"); + } + if($steps === FALSE){ + throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'steps' is missing"); + } + // Steps should be between -255 and 255. Negative = darker, positive = lighter + $steps = max(-255, min(255, $steps)); + + // Normalize into a six character long hex string + $hex = str_replace('#', '', $hex); + if (strlen($hex) == 3) { + $hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2); + } + + // Split into three parts: R, G and B + $color_parts = str_split($hex, 2); + $return = '#'; + + foreach ($color_parts as $color) { + $color = hexdec($color); // Convert to decimal + $color = max(0,min(255,$color + $steps)); // Adjust color + $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code + } + return $return; + } + public static function debug($data=FALSE){ if($data != FALSE){ ob_start();
0
db24063b01cba8e9d4d88b7d8ac70c9000c104e4
https://github.com/the-tcpdump-group/tcpdump/commit/db24063b01cba8e9d4d88b7d8ac70c9000c104e4
CVE-2017-12989/RESP: Make sure resp_get_length() advances the pointer for invalid lengths. Make sure that it always sends *endp before returning and that, for invalid lengths where we don't like a character in the length string, what it sets *endp to is past the character in question, so we don't run the risk of infinitely looping (or doing something else random) if a character in the length is invalid. This fixes an infinite loop discovered by Forcepoint's security researchers Otto Airamo & Antti Levomäki. Add a test using the capture file supplied by the reporter(s).
diff --git a/print-resp.c b/print-resp.c index 9d71e21dc..dee22d63a 100644 --- a/print-resp.c +++ b/print-resp.c @@ -481,8 +481,10 @@ resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, con ND_TCHECK(*bp); c = *bp; if (!(c >= '0' && c <= '9')) { - if (!saw_digit) + if (!saw_digit) { + bp++; goto invalid; + } break; } c -= '0'; @@ -510,15 +512,19 @@ resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, con if (len == 0) goto trunc; ND_TCHECK(*bp); - if (*bp != '\r') + if (*bp != '\r') { + bp++; goto invalid; + } bp++; len--; if (len == 0) goto trunc; ND_TCHECK(*bp); - if (*bp != '\n') + if (*bp != '\n') { + bp++; goto invalid; + } bp++; len--; *endp = bp; @@ -531,8 +537,10 @@ resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, con return (too_large ? -3 : result); trunc: + *endp = bp; return (-2); invalid: + *endp = bp; return (-5); } diff --git a/tests/TESTLIST b/tests/TESTLIST index e0f0bb146..ecf54f69b 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -468,6 +468,7 @@ zephyr-oobr zephyr-oobr.pcap zephyr-oobr.out -vvv -e bgp-as-path-oobr bgp-as-path-oobr.pcap bgp-as-path-oobr.out -vvv -e isakmp-no-none-np isakmp-no-none-np.pcap isakmp-no-none-np.out -vvv -e telnet-iac-check-oobr telnet-iac-check-oobr.pcap telnet-iac-check-oobr.out -vvv -e +resp_4_infiniteloop resp_4_infiniteloop.pcap resp_4_infiniteloop.out -vvv -e # RTP tests # fuzzed pcap diff --git a/tests/resp_4_infiniteloop.out b/tests/resp_4_infiniteloop.out new file mode 100644 index 000000000..396cb8b39 --- /dev/null +++ b/tests/resp_4_infiniteloop.out @@ -0,0 +1,2 @@ +00:50:56:b4:08:69 > 00:50:56:b4:4c:2a, ethertype IPv4 (0x0800), length 920: (tos 0x0, ttl 64, id 27576, offset 0, flags [DF], proto TCP (6), length 906) + 172.16.8.77.33926 > 172.16.8.149.6379: Flags [P.], cksum 0xa129 (incorrect -> 0xaaa0), seq 3839414413:3839415267, ack 2526552240, win 229, options [nop,nop,TS val 2407226 ecr 24894817], length 854: RESP length negative and not -1 invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid "4" "EVAL" invalid invalid invalid invalid "GKMbNZq^@0" "stuubt.pack('<ivdMFG4294967245',^V ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''319', 2',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',',', '-1494241318543828858')'L')N))'r')')~D')')E)')')')')')')')'l')')')')')'M-`'o')')'Pp)U)" invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid invalid "1" [|RESP] diff --git a/tests/resp_4_infiniteloop.pcap b/tests/resp_4_infiniteloop.pcap new file mode 100644 index 000000000..98a79bfb6 Binary files /dev/null and b/tests/resp_4_infiniteloop.pcap differ
1
23249c726311bb7822aea54bdddd2ef5ab69e32f
https://github.com/kanaka/noVNC/commit/23249c726311bb7822aea54bdddd2ef5ab69e32f
Store result from NPM and snap builds To ease debugging.
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 781309bcf..9d52eb354 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,6 +16,10 @@ jobs: # Needs to be explicitly specified for auth to work registry-url: 'https://registry.npmjs.org' - run: npm install + - uses: actions/upload-artifact@v2 + with: + name: npm + path: lib - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} @@ -40,6 +44,10 @@ jobs: echo $VERSION sed -i "s/@VERSION@/$VERSION/g" snap/snapcraft.yaml - run: snapcraft + - uses: actions/upload-artifact@v2 + with: + name: snap + path: novnc*.snap - run: | mkdir .snapcraft echo ${SNAPCRAFT_LOGIN} | base64 --decode --ignore-garbage > .snapcraft/snapcraft.cfg
0
181a4969290f1c756089b2993a638fe403bc1314
https://github.com/beobal/cassandra/commit/181a4969290f1c756089b2993a638fe403bc1314
Prepare debian changelog for 3.11.10
diff --git a/debian/changelog b/debian/changelog index 3dae39e9278..e2fb01e8067 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -cassandra (3.11.10) UNRELEASED; urgency=medium +cassandra (3.11.10) unstable; urgency=medium * New release - -- Mick Semb Wever <[email protected]> Thu, 29 Oct 2020 12:32:12 +0100 + -- Alex Petrov <[email protected]> Fri, 29 Jan 2021 13:27:39 +0100 cassandra (3.11.9) unstable; urgency=medium
0
2e3c3a87d81e16a2fed442c1cf31360f75737a83
https://github.com/josh/rails/commit/2e3c3a87d81e16a2fed442c1cf31360f75737a83
Only use valid mime type symbols as cache keys CVE-2013-6414
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index f9d5b97fe3655..c6ff683827d43 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -62,6 +62,13 @@ class DetailsKey #:nodoc: @details_keys = ThreadSafe::Cache.new def self.get(details) + if details[:formats] + details = details.dup + syms = Set.new Mime::SET.symbols + details[:formats] = details[:formats].select { |v| + syms.include? v + } + end @details_keys[details] ||= new end
1
a321ca69c34729f4a0d0599ac1da09f0d53f6602
https://github.com/fosnola/libstaroffice/commit/a321ca69c34729f4a0d0599ac1da09f0d53f6602
configure.ac: change minor version to prepare a release...
diff --git a/configure.ac b/configure.ac index 52c96ef..62fb72c 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_PREREQ([2.65]) # ==================== m4_define([libstaroffice_version_major],[0]) m4_define([libstaroffice_version_minor],[0]) -m4_define([libstaroffice_version_micro],[5]) +m4_define([libstaroffice_version_micro],[6]) m4_define([libstaroffice_version],[libstaroffice_version_major.libstaroffice_version_minor.libstaroffice_version_micro]) # =============
0
6406a90a36814bdfcfa22898211ae8fff2ae7e5b
https://github.com/mycolorway/simditor/commit/6406a90a36814bdfcfa22898211ae8fff2ae7e5b
CHG: 链接支持 mailto 和 tel
diff --git a/lib/simditor.js b/lib/simditor.js index fa60366b..95a5e6e8 100644 --- a/lib/simditor.js +++ b/lib/simditor.js @@ -4217,7 +4217,7 @@ LinkPopover = (function(superClass) { return; } val = _this.urlEl.val(); - if (!(/^(http|https|ftp|ftps|file)?:\/\/|^\//ig.test(val) || !val)) { + if (!(/^(http|https|ftp|ftps|file)?:\/\/|^(mailto|tel)?:|^\//ig.test(val) || !val)) { val = 'http://' + val; } _this.target.attr('href', val); diff --git a/site/assets/scripts/simditor.js b/site/assets/scripts/simditor.js index fa60366b..95a5e6e8 100644 --- a/site/assets/scripts/simditor.js +++ b/site/assets/scripts/simditor.js @@ -4217,7 +4217,7 @@ LinkPopover = (function(superClass) { return; } val = _this.urlEl.val(); - if (!(/^(http|https|ftp|ftps|file)?:\/\/|^\//ig.test(val) || !val)) { + if (!(/^(http|https|ftp|ftps|file)?:\/\/|^(mailto|tel)?:|^\//ig.test(val) || !val)) { val = 'http://' + val; } _this.target.attr('href', val); diff --git a/src/buttons/link.coffee b/src/buttons/link.coffee index f1f8b343..79d143a0 100644 --- a/src/buttons/link.coffee +++ b/src/buttons/link.coffee @@ -100,7 +100,7 @@ class LinkPopover extends Popover return if e.which == 13 val = @urlEl.val() - val = 'http://' + val unless /^(http|https|ftp|ftps|file)?:\/\/|^\//ig.test(val) or !val + val = 'http://' + val unless /^(http|https|ftp|ftps|file)?:\/\/|^(mailto|tel)?:|^\//ig.test(val) or !val @target.attr 'href', val @editor.inputManager.throttledValueChanged()
0
e32ec73315cb7dc9c295efeb5e818edc7830418d
https://github.com/GNOME/gnome-shell/commit/e32ec73315cb7dc9c295efeb5e818edc7830418d
workspaceAnimation: Extract WorkspaceGroup Simplify the code a bit. The workspace group is relatively self-contained, so split it from the general animation. Reimplement _syncStacking(). This will help a lot later, with workspace strip and multi-monitor support. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1326>
diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js index 17002667e0..e48a03061a 100644 --- a/js/ui/workspaceAnimation.js +++ b/js/ui/workspaceAnimation.js @@ -1,20 +1,95 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported WorkspaceAnimationController */ -const { Clutter, Meta, Shell } = imports.gi; +const { Clutter, GObject, Meta, Shell } = imports.gi; const Main = imports.ui.main; const SwipeTracker = imports.ui.swipeTracker; const WINDOW_ANIMATION_TIME = 250; +const WorkspaceGroup = GObject.registerClass( +class WorkspaceGroup extends Clutter.Actor { + _init(workspace, movingWindow) { + super._init(); + + this._workspace = workspace; + this._movingWindow = movingWindow; + this._windowRecords = []; + + this._createWindows(); + + this.connect('destroy', this._onDestroy.bind(this)); + this._restackedId = global.display.connect('restacked', + this._syncStacking.bind(this)); + } + + _shouldShowWindow(window) { + if (!window.showing_on_its_workspace()) + return false; + + const isSticky = + window.is_on_all_workspaces() || window === this._movingWindow; + + return !isSticky && window.located_on_workspace(this._workspace); + } + + _syncStacking() { + const windowActors = global.get_window_actors(); + let lastSibling = null; + + for (const windowActor of windowActors) { + this.set_child_above_sibling(windowActor, lastSibling); + lastSibling = windowActor; + } + } + + _createWindows() { + const windowActors = global.get_window_actors().filter(w => + this._shouldShowWindow(w.meta_window)); + + for (const windowActor of windowActors) { + const record = { + windowActor, + parent: windowActor.get_parent(), + }; + + record.parent.remove_child(windowActor); + this.add_child(windowActor); + windowActor.show(); + + record.windowDestroyId = windowActor.connect('destroy', () => { + this._windowRecords.splice(this._windowRecords.indexOf(record), 1); + }); + + this._windowRecords.push(record); + } + } + + _removeWindows() { + for (const record of this._windowRecords) { + record.windowActor.disconnect(record.windowDestroyId); + this.remove_child(record.windowActor); + record.parent.add_child(record.windowActor); + + if (!this._workspace.active) + record.windowActor.hide(); + } + + this._windowRecords = []; + } + + _onDestroy() { + global.display.disconnect(this._restackedId); + this._removeWindows(); + } +}); + var WorkspaceAnimationController = class { constructor() { this._movingWindow = null; this._switchData = null; - global.display.connect('restacked', this._syncStacking.bind(this)); - Main.overview.connect('showing', () => { if (this._switchData) { if (this._switchData.gestureActivated) @@ -34,35 +109,6 @@ var WorkspaceAnimationController = class { this._swipeTracker = swipeTracker; } - _syncStacking() { - if (this._switchData === null) - return; - - const windows = global.get_window_actors(); - let lastCurSibling = null; - const lastDirSibling = []; - for (let i = 0; i < windows.length; i++) { - if (windows[i].get_parent() === this._switchData.curGroup) { - this._switchData.curGroup.set_child_above_sibling(windows[i], lastCurSibling); - lastCurSibling = windows[i]; - } else { - for (const dir of Object.values(Meta.MotionDirection)) { - const info = this._switchData.surroundings[dir]; - if (!info || windows[i].get_parent() !== info.actor) - continue; - - let sibling = lastDirSibling[dir]; - if (sibling === undefined) - sibling = null; - - info.actor.set_child_above_sibling(windows[i], sibling); - lastDirSibling[dir] = windows[i]; - break; - } - } - } - } - _getPositionForDirection(direction, fromWs, toWs) { let xDest = 0, yDest = 0; @@ -100,13 +146,15 @@ var WorkspaceAnimationController = class { return; const wgroup = global.window_group; - const windows = global.get_window_actors(); + const workspaceManager = global.workspace_manager; + const curWs = workspaceManager.get_workspace_by_index(from); + const switchData = {}; this._switchData = switchData; - switchData.curGroup = new Clutter.Actor(); + switchData.curGroup = new WorkspaceGroup(curWs, this.movingWindow); switchData.movingWindowBin = new Clutter.Actor(); - switchData.windows = []; + switchData.movingWindow = null; switchData.surroundings = {}; switchData.gestureActivated = false; switchData.inProgress = false; @@ -117,9 +165,6 @@ var WorkspaceAnimationController = class { wgroup.add_child(switchData.movingWindowBin); wgroup.add_child(switchData.container); - const workspaceManager = global.workspace_manager; - const curWs = workspaceManager.get_workspace_by_index(from); - for (const dir of Object.values(Meta.MotionDirection)) { let ws = null; @@ -134,66 +179,28 @@ var WorkspaceAnimationController = class { } const [x, y] = this._getPositionForDirection(dir, curWs, ws); - const info = { - index: ws.index(), - actor: new Clutter.Actor(), - xDest: x, - yDest: y, - }; - switchData.surroundings[dir] = info; - switchData.container.add_child(info.actor); - switchData.container.set_child_above_sibling(info.actor, null); + const group = new WorkspaceGroup(ws, this.movingWindow); + switchData.surroundings[dir] = group; + switchData.container.add_child(group); + switchData.container.set_child_above_sibling(group, null); - info.actor.set_position(x, y); + group.set_position(x, y); } wgroup.set_child_above_sibling(switchData.movingWindowBin, null); - for (const windowActor of windows) { - const window = windowActor.get_meta_window(); - - if (!window.showing_on_its_workspace()) - continue; + if (this.movingWindow) { + const windowActor = this.movingWindow.get_compositor_private(); - if (window.is_on_all_workspaces()) - continue; - - const record = { + switchData.movingWindow = { windowActor, parent: windowActor.get_parent(), }; - if (this.movingWindow && window === this.movingWindow) { - record.parent.remove_child(windowActor); - switchData.movingWindow = record; - switchData.windows.push(switchData.movingWindow); - switchData.movingWindowBin.add_child(windowActor); - } else if (window.get_workspace().index() === from) { - record.parent.remove_child(windowActor); - switchData.windows.push(record); - switchData.curGroup.add_child(windowActor); - } else { - let visible = false; - for (const dir of Object.values(Meta.MotionDirection)) { - const info = switchData.surroundings[dir]; - - if (!info || info.index !== window.get_workspace().index()) - continue; - - record.parent.remove_child(windowActor); - switchData.windows.push(record); - info.actor.add_child(windowActor); - visible = true; - break; - } - - windowActor.visible = visible; - } - } - - for (const record of switchData.windows) { - record.windowDestroyId = record.windowActor.connect('destroy', () => { - switchData.windows.splice(switchData.windows.indexOf(record), 1); + switchData.movingWindow.parent.remove_child(windowActor); + switchData.movingWindowBin.add_child(windowActor); + switchData.movingWindow.windowDestroyId = windowActor.connect('destroy', () => { + switchData.movingWindow = null; }); } } @@ -201,14 +208,15 @@ var WorkspaceAnimationController = class { _finishWorkspaceSwitch(switchData) { this._switchData = null; - for (const record of switchData.windows) { + if (switchData.movingWindow) { + const record = switchData.movingWindow; record.windowActor.disconnect(record.windowDestroyId); switchData.movingWindowBin.remove_child(record.windowActor); record.parent.add_child(record.windowActor); - if (!record.windowActor.get_meta_window().get_workspace().active) - record.windowActor.hide(); + switchData.movingWindow = null; } + switchData.container.destroy(); switchData.movingWindowBin.destroy(); @@ -275,16 +283,16 @@ var WorkspaceAnimationController = class { baseDistance = global.screen_height; let direction = this._directionForProgress(-1); - let info = this._switchData.surroundings[direction]; - if (info !== null) { - const distance = horiz ? info.xDest : info.yDest; + let group = this._switchData.surroundings[direction]; + if (group !== null) { + const distance = horiz ? group.x : group.y; lower = -Math.abs(distance) / baseDistance; } direction = this._directionForProgress(1); - info = this._switchData.surroundings[direction]; - if (info !== null) { - const distance = horiz ? info.xDest : info.yDest; + group = this._switchData.surroundings[direction]; + if (group !== null) { + const distance = horiz ? group.x : group.y; upper = Math.abs(distance) / baseDistance; } @@ -343,10 +351,10 @@ var WorkspaceAnimationController = class { return; const direction = this._directionForProgress(progress); - const info = this._switchData.surroundings[direction]; + const group = this._switchData.surroundings[direction]; let xPos = 0; let yPos = 0; - if (info) { + if (group) { if (global.workspace_manager.layout_rows === -1) yPos = -Math.round(progress * global.screen_height); else if (Clutter.get_default_text_direction() === Clutter.TextDirection.RTL) @@ -370,8 +378,8 @@ var WorkspaceAnimationController = class { if (endProgress !== 0) { const direction = this._directionForProgress(endProgress); newWs = activeWorkspace.get_neighbor(direction); - xDest = -this._switchData.surroundings[direction].xDest; - yDest = -this._switchData.surroundings[direction].yDest; + xDest = -this._switchData.surroundings[direction].x; + yDest = -this._switchData.surroundings[direction].y; } const switchData = this._switchData;
0
2cc81253ff4d62c03af7e7548b65770552bcdc6c
https://github.com/apache/cordova-android/commit/2cc81253ff4d62c03af7e7548b65770552bcdc6c
cleanup: remove trailing spaces from bat files (#996) * remove trailing spaces from bin/*.bat * remove trailing spaces from bin/templates/cordova/lib/*.bat
diff --git a/bin/android_sdk_version.bat b/bin/android_sdk_version.bat index a6bc104359..65173a8f8f 100644 --- a/bin/android_sdk_version.bat +++ b/bin/android_sdk_version.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/check_reqs.bat b/bin/check_reqs.bat index 846dfa1f48..84d66ad20d 100644 --- a/bin/check_reqs.bat +++ b/bin/check_reqs.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/create.bat b/bin/create.bat index 4b475a2a90..308fbccf85 100644 --- a/bin/create.bat +++ b/bin/create.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,4 +23,4 @@ IF EXIST %script_path% ( ECHO. ECHO ERROR: Could not find 'create' script in 'bin' folder, aborting...>&2 EXIT /B 1 -) \ No newline at end of file +) diff --git a/bin/templates/cordova/lib/install-device.bat b/bin/templates/cordova/lib/install-device.bat index 109b470ebf..0be9ebd030 100644 --- a/bin/templates/cordova/lib/install-device.bat +++ b/bin/templates/cordova/lib/install-device.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/templates/cordova/lib/install-emulator.bat b/bin/templates/cordova/lib/install-emulator.bat index a28c23a185..21e88c530d 100644 --- a/bin/templates/cordova/lib/install-emulator.bat +++ b/bin/templates/cordova/lib/install-emulator.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/templates/cordova/lib/list-devices.bat b/bin/templates/cordova/lib/list-devices.bat index ad5f03ed0c..7e04cf9462 100644 --- a/bin/templates/cordova/lib/list-devices.bat +++ b/bin/templates/cordova/lib/list-devices.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/templates/cordova/lib/list-emulator-images.bat b/bin/templates/cordova/lib/list-emulator-images.bat index 616ffb7517..55c399d7ad 100644 --- a/bin/templates/cordova/lib/list-emulator-images.bat +++ b/bin/templates/cordova/lib/list-emulator-images.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,7 +20,7 @@ SET script_path="%~dp0list-emulator-images" IF EXIST %script_path% ( node %script_path% %* ) ELSE ( - ECHO. + ECHO. ECHO ERROR: Could not find 'list-emulator-images' script in 'cordova\lib' folder, aborting...>&2 EXIT /B 1 ) diff --git a/bin/templates/cordova/lib/list-started-emulators.bat b/bin/templates/cordova/lib/list-started-emulators.bat index eed02a5c5a..99547aa4d4 100644 --- a/bin/templates/cordova/lib/list-started-emulators.bat +++ b/bin/templates/cordova/lib/list-started-emulators.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/templates/cordova/lib/start-emulator.bat b/bin/templates/cordova/lib/start-emulator.bat index 6c237ea2a6..82c6f8908e 100644 --- a/bin/templates/cordova/lib/start-emulator.bat +++ b/bin/templates/cordova/lib/start-emulator.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/bin/update.bat b/bin/update.bat index d0aa7a0149..824d9af85c 100644 --- a/bin/update.bat +++ b/bin/update.bat @@ -5,9 +5,9 @@ :: to you under the Apache License, Version 2.0 (the :: "License"); you may not use this file except in compliance :: with the License. You may obtain a copy of the License at -:: +:: :: http://www.apache.org/licenses/LICENSE-2.0 -:: +:: :: Unless required by applicable law or agreed to in writing, :: software distributed under the License is distributed on an :: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0
a65073657834ff5e4054a5a44af0fc420c62eba5
https://github.com/andrzuk/FineCMS/commit/a65073657834ff5e4054a5a44af0fc420c62eba5
Protection against 'headers already sent' warning.
diff --git a/index.php b/index.php index ccf16b7..aee5f3e 100644 --- a/index.php +++ b/index.php @@ -1,54 +1,58 @@ -<?php - -session_start(); - -if (!isset($_SESSION['init'])) -{ - session_regenerate_id(); - $_SESSION['init'] = TRUE; - $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; -} -if ($_SERVER['REMOTE_ADDR'] != $_SESSION['ip']) -{ - session_destroy(); -} - -error_reporting(E_ALL); - -include 'config/config.php'; - -include CLASS_DIR . 'application.php'; - -$app = new Application(); - -$app->start(); - -if (isset($_GET['route'])) -{ - $routing = explode('&', $_GET['route']); - $route_controller = APP_DIR . 'controller/' . trim($routing[0]) . '.php'; - - if (!file_exists($route_controller)) - { - $route_controller = APP_DIR . 'controller/index.php'; - } -} -else -{ - $route_controller = APP_DIR . 'controller/index.php'; -} - -if (isset($_SESSION['install_mode'])) -{ - $route_controller = APP_DIR . 'controller/install.php'; -} - -$route_action = isset($_GET['action']) ? $_GET['action'] : 'index'; - -$app->set_controller($route_controller, $route_action); - -$app->get_page()->render(); - -$app->stop(); - -?> +<?php + +session_start(); + +if (!isset($_SESSION['init'])) +{ + session_regenerate_id(); + $_SESSION['init'] = TRUE; + $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; +} +if ($_SERVER['REMOTE_ADDR'] != $_SESSION['ip']) +{ + session_destroy(); +} + +error_reporting(E_ALL); + +ob_start(); + +include 'config/config.php'; + +include CLASS_DIR . 'application.php'; + +$app = new Application(); + +$app->start(); + +if (isset($_GET['route'])) +{ + $routing = explode('&', $_GET['route']); + $route_controller = APP_DIR . 'controller/' . trim($routing[0]) . '.php'; + + if (!file_exists($route_controller)) + { + $route_controller = APP_DIR . 'controller/index.php'; + } +} +else +{ + $route_controller = APP_DIR . 'controller/index.php'; +} + +if (isset($_SESSION['install_mode'])) +{ + $route_controller = APP_DIR . 'controller/install.php'; +} + +$route_action = isset($_GET['action']) ? $_GET['action'] : 'index'; + +$app->set_controller($route_controller, $route_action); + +$app->get_page()->render(); + +$app->stop(); + +ob_end_flush(); + +?>
0
ce66c4408c2fe0db526b4cd915c765a009f3084f
https://github.com/jokkedk/webgrind/commit/ce66c4408c2fe0db526b4cd915c765a009f3084f
Escape Shell Injection Due to `$dataFile` being read in by `$_GET`, this enables a remote attacker to inject shell commands and run as PHP on the remote server, enabling Remote Code Execution. `escapeshellarg` will stop the immediate direct injection threat, however additional sanitization should be performed to ensure no inputs can result in overwritten files, etc.
diff --git a/index.php b/index.php index 399b7ad..596973f 100644 --- a/index.php +++ b/index.php @@ -148,7 +148,7 @@ class Webgrind_MasterConfig header("Content-Type: image/png"); $filename = Webgrind_Config::storageDir().$dataFile.'-'.$showFraction.Webgrind_Config::$preprocessedSuffix.'.png'; if (!file_exists($filename)) { - shell_exec(Webgrind_Config::$pythonExecutable.' library/gprof2dot.py -n '.$showFraction.' -f callgrind '.Webgrind_Config::xdebugOutputDir().''.$dataFile.' | '.Webgrind_Config::$dotExecutable.' -Tpng -o ' . $filename); + shell_exec(Webgrind_Config::$pythonExecutable.' library/gprof2dot.py -n '.$showFraction.' -f callgrind '.Webgrind_Config::xdebugOutputDir().''.escapeshellarg($dataFile).' | '.Webgrind_Config::$dotExecutable.' -Tpng -o ' . escapeshellarg($filename)); } readfile($filename); break;
1
77b2631c78461965bc9a7414aae206b5c514e1b3
https://github.com/irssi/irssi/commit/77b2631c78461965bc9a7414aae206b5c514e1b3
Merge branch 'netjoin-timeout' into 'master' fe-netjoin: remove irc servers on "server disconnected" signal Closes #7 See merge request !10
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c index 4eb388c05..8272093fe 100644 --- a/src/fe-common/irc/fe-netjoin.c +++ b/src/fe-common/irc/fe-netjoin.c @@ -470,6 +470,20 @@ static void read_settings(void) } } +static void sig_server_disconnected(IRC_SERVER_REC *server) +{ + NETJOIN_SERVER_REC *netjoin_server; + + g_return_if_fail(server != NULL); + + if (!IS_IRC_SERVER(server)) + return; + + if ((netjoin_server = netjoin_find_server(server))) { + netjoin_server_remove(netjoin_server); + } +} + void fe_netjoin_init(void) { settings_add_bool("misc", "hide_netsplit_quits", TRUE); @@ -480,6 +494,7 @@ void fe_netjoin_init(void) read_settings(); signal_add("setup changed", (SIGNAL_FUNC) read_settings); + signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); } void fe_netjoin_deinit(void) @@ -492,6 +507,7 @@ void fe_netjoin_deinit(void) } signal_remove("setup changed", (SIGNAL_FUNC) read_settings); + signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); signal_remove("message quit", (SIGNAL_FUNC) msg_quit); signal_remove("message join", (SIGNAL_FUNC) msg_join);
1
42f3d5c0bdaff80dfbe62ae78a40e00f72db8841
https://github.com/BradLarson/GPUImage/commit/42f3d5c0bdaff80dfbe62ae78a40e00f72db8841
There is an issue in GPUImageMovie - when instance adds itself as AVPlayerItemVideoOutput delegate: [playerItemOutput setDelegate:self queue:videoProcessingQueue], playerItemOutput doesn't release its delegate when GPUImageMovie instance is deallocating. Later, this results in a method call from the deallocated object (outputSequenceWasFlushed:) and you get the crash. This was found with help of NSZombie detector and I fixed it by adding this in GPUImageMovie dealloc method: [playerItemOutput setDelegate:nil queue:nil];
diff --git a/framework/Source/GPUImageMovie.m b/framework/Source/GPUImageMovie.m index d096b03ee..9e9e98ea2 100755 --- a/framework/Source/GPUImageMovie.m +++ b/framework/Source/GPUImageMovie.m @@ -134,6 +134,8 @@ - (void)yuvConversionSetup; - (void)dealloc { + [playerItemOutput setDelegate:nil queue:nil]; + // Moved into endProcessing //if (self.playerItem && (displayLink != nil)) //{
0
f457e443e2ac90504a7d7c11f435855975c64e1e
https://github.com/facebook/proxygen/commit/f457e443e2ac90504a7d7c11f435855975c64e1e
Updating submodules Summary: GitHub commits: https://github.com/facebook/fb303/commit/292b42257e3c7f2221e5b09ec2b272a7843a7dd2 https://github.com/facebook/fbthrift/commit/b451673dac0a7252e02a92e25588a816a99530a2 https://github.com/facebook/fbzmq/commit/e7b84a4929aff439cf483d23620069e14b3773cb https://github.com/facebook/folly/commit/f184a28f2f5938bbf49883182f082a27dbaf5373 https://github.com/facebook/proxygen/commit/4b2937d95b67963c134327ae72980cc56f663e29 https://github.com/facebook/wangle/commit/1cad7c184b2c9731953165e5b45388a6d3561658 https://github.com/facebook/watchman/commit/452ea1031299778c534181f20ac01d41abb1fbd4 https://github.com/facebookexperimental/rust-shed/commit/a834db0dfb6c063edd6080661437cc6b97753bb8 https://github.com/facebookincubator/fizz/commit/1254ff17b2b81aa20ed5fbfa587720732fd48d05 https://github.com/facebookincubator/katran/commit/30aa723292c53553554d53a3621e58695700d59a https://github.com/facebookincubator/mvfst/commit/ef3ed3b97b214aa650a56f429dfc3f70814b80bc https://github.com/pytorch/fbgemm/commit/5fda125eb5afaf033ee19f74766789135c4dd16e https://github.com/rsocket/rsocket-cpp/commit/816259d53fecebf64ff4ffd4a9f9a03e12f78190 Reviewed By: 2d2d2d2d2d fbshipit-source-id: 6b0e91a44fc3a0027361b7988f206d400137478f
diff --git a/build/deps/github_hashes/facebook/folly-rev.txt b/build/deps/github_hashes/facebook/folly-rev.txt index 7b2df9234..442a92ce3 100644 --- a/build/deps/github_hashes/facebook/folly-rev.txt +++ b/build/deps/github_hashes/facebook/folly-rev.txt @@ -1 +1 @@ -Subproject commit bc4e31a8e529267cc53bc16c4fe9637555302fab +Subproject commit f184a28f2f5938bbf49883182f082a27dbaf5373 diff --git a/build/deps/github_hashes/facebook/wangle-rev.txt b/build/deps/github_hashes/facebook/wangle-rev.txt index 9e207cb2f..f102e0ae0 100644 --- a/build/deps/github_hashes/facebook/wangle-rev.txt +++ b/build/deps/github_hashes/facebook/wangle-rev.txt @@ -1 +1 @@ -Subproject commit db1b8741f6ec98920a50859a37bc731d04e4b01b +Subproject commit 1cad7c184b2c9731953165e5b45388a6d3561658 diff --git a/build/deps/github_hashes/facebookincubator/fizz-rev.txt b/build/deps/github_hashes/facebookincubator/fizz-rev.txt index bb5d8e4af..0732a1885 100644 --- a/build/deps/github_hashes/facebookincubator/fizz-rev.txt +++ b/build/deps/github_hashes/facebookincubator/fizz-rev.txt @@ -1 +1 @@ -Subproject commit 330eb78ac7a734174a85f35e0f6509697f3a8092 +Subproject commit 1254ff17b2b81aa20ed5fbfa587720732fd48d05 diff --git a/build/deps/github_hashes/facebookincubator/mvfst-rev.txt b/build/deps/github_hashes/facebookincubator/mvfst-rev.txt index c2a36137b..14e51fce2 100644 --- a/build/deps/github_hashes/facebookincubator/mvfst-rev.txt +++ b/build/deps/github_hashes/facebookincubator/mvfst-rev.txt @@ -1 +1 @@ -Subproject commit 4d444cccd7101de02bbac41d236b83486190f8c4 +Subproject commit ef3ed3b97b214aa650a56f429dfc3f70814b80bc
0
3dfda493d8adcc4e8dba104eaba418301fd18fd6
https://github.com/rofl0r/proxychains-ng/commit/3dfda493d8adcc4e8dba104eaba418301fd18fd6
only start allocator thread if proxy_dns is requested this should fix problems with programs that do whacky non-async-signal-safe stuff.
diff --git a/src/libproxychains.c b/src/libproxychains.c index ab0aaff..ad4809b 100644 --- a/src/libproxychains.c +++ b/src/libproxychains.c @@ -116,19 +116,22 @@ static void setup_hooks(void) { SETUP_SYM(freeaddrinfo); SETUP_SYM(gethostbyaddr); SETUP_SYM(getnameinfo); - SETUP_SYM(close); #ifdef IS_SOLARIS SETUP_SYM(__xnet_connect); #endif + SETUP_SYM(close); } static int close_fds[16]; static int close_fds_cnt = 0; +static void rdns_init(void) { + at_init(); +} + static void do_init(void) { srand(time(NULL)); core_initialize(); - at_init(); /* read the config file */ get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct); @@ -139,8 +142,9 @@ static void do_init(void) { setup_hooks(); while(close_fds_cnt) true_close(close_fds[--close_fds_cnt]); - init_l = 1; + + if(proxychains_resolver) rdns_init(); } static void init_lib_wrapper(const char* caller) { @@ -500,6 +504,8 @@ int close(int fd) { errno = 0; return 0; } + if(!proxychains_resolver) return true_close(fd); + /* prevent rude programs (like ssh) from closing our pipes */ if(fd != req_pipefd[0] && fd != req_pipefd[1] && fd != resp_pipefd[0] && fd != resp_pipefd[1]) {
0
2924b410f9dec8234523884fcae70ff7291bd094
https://github.com/puppetlabs/puppet/commit/2924b410f9dec8234523884fcae70ff7291bd094
(maint) Add show legacy option for puppet facts
diff --git a/lib/puppet/face/facts.rb b/lib/puppet/face/facts.rb index c48e2062a9d..2f778e2b2bb 100644 --- a/lib/puppet/face/facts.rb +++ b/lib/puppet/face/facts.rb @@ -128,6 +128,10 @@ summary _("Disable legacy facts when querying all facts.") end + option("--show-legacy") do + summary _("Show legacy facts when querying all facts.") + end + when_invoked do |*args| options = args.pop
0
2a249b0bac6e7cf3cb743c909e1ace41b7a8970e
https://github.com/shadowsocks/shadowsocks-libev/commit/2a249b0bac6e7cf3cb743c909e1ace41b7a8970e
added support for Docker secrets and password file in the Docker image this means we no longer have to hardcode the password in the docker-compose file, and can treat the file as configuration rather than a secret.
diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index 304212e45..92cd62986 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -48,12 +48,6 @@ RUN set -ex \ USER nobody -CMD exec ss-server \ - -s $SERVER_ADDR \ - -p $SERVER_PORT \ - -k ${PASSWORD:-$(hostname)} \ - -m $METHOD \ - -t $TIMEOUT \ - -d $DNS_ADDRS \ - -u \ - $ARGS +COPY ./docker/alpine/entrypoint.sh /entrypoint.sh + +CMD /entrypoint.sh diff --git a/docker/alpine/README.md b/docker/alpine/README.md index 04ae9ed08..e347997c0 100644 --- a/docker/alpine/README.md +++ b/docker/alpine/README.md @@ -56,6 +56,32 @@ $ docker run -e PASSWORD=9MLSpPmNt -p 8388:8388 -p 8388:8388/udp -d --restart al ``` > :warning: Click [here][6] to generate a strong password to protect your server. +### With password as a mounted file or a Docker secret (swarm only) + +Instead of hardcoding a password to the docker-compose file or `docker run` command, you can mount in a file that contains the password. To do so, pass the path that you mounted to the container as the `PASSWORD_FILE` environment variable. + +If you are running Docker Swarm, you can also utilize Docker secrets. To do so, pass the name of the secret as the `PASSWORD_SECRET` environment variable. If you specify both `PASSWORD_FILE` and `PASSWORD_SECRET`, the latter will take effect. + +This is a sample `docker-compose.yml` file that uses the external Docker secret named `shadowsocks` as the password. + +```yaml +shadowsocks: + image: shadowsocks/shadowsocks-libev + ports: + - "8388:8388" + environment: + - METHOD=aes-256-gcm + - PASSWORD_SECRET=shadowsocks + secrets: + - shadowsocks +``` + +This is a sample `docker service create` command that uses the external Docker secret named `shadowsocks` as the password. + +```bash +docker service create -e PASSWORD_SECRET=shadowsocks -p 8388:8388 -p 8388:8388/udp --secret shadowsocks shadowsocks/shadowsocks-libev +``` + ### With other customizations Besides `PASSWORD`, the image also defines the following environment variables that you can customize: * `SERVER_ADDR`: the IP/domain to bind to, defaults to `0.0.0.0` diff --git a/docker/alpine/entrypoint.sh b/docker/alpine/entrypoint.sh new file mode 100755 index 000000000..c3655efe8 --- /dev/null +++ b/docker/alpine/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +if [[ -f "$PASSWORD_FILE" ]]; then + PASSWORD=$(cat "$PASSWORD_FILE") +fi + +if [[ -f "/var/run/secrets/$PASSWORD_SECRET" ]]; then + PASSWORD=$(cat "/var/run/secrets/$PASSWORD_SECRET") +fi + +exec ss-server \ + -s $SERVER_ADDR \ + -p $SERVER_PORT \ + -k ${PASSWORD:-$(hostname)} \ + -m $METHOD \ + -t $TIMEOUT \ + -d $DNS_ADDRS \ + -u \ + $ARGS
0
ed64d18d21cbd139f8b4ef9fe588f2ac3dd4086d
https://github.com/javamelody/javamelody/commit/ed64d18d21cbd139f8b4ef9fe588f2ac3dd4086d
upgrade test dependencies
diff --git a/javamelody-core/pom.xml b/javamelody-core/pom.xml index d25f173b4..3d8a9e9d0 100644 --- a/javamelody-core/pom.xml +++ b/javamelody-core/pom.xml @@ -110,7 +110,7 @@ <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> - <version>2.13.0</version> + <version>2.13.3</version> <optional>true</optional> </dependency> <dependency> @@ -170,7 +170,7 @@ <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> - <version>1.4.11.1</version> + <version>1.4.12</version> <optional>true</optional> </dependency> <dependency> @@ -214,19 +214,19 @@ <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> - <version>5.2.3.RELEASE</version> + <version>5.2.7.RELEASE</version> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> - <version>5.2.3.RELEASE</version> + <version>5.2.7.RELEASE</version> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> - <version>5.2.3.RELEASE</version> + <version>5.2.7.RELEASE</version> <scope>test</scope> </dependency> <dependency> @@ -238,21 +238,21 @@ <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-elasticsearch</artifactId> - <version>3.2.4.RELEASE</version> + <version>4.0.1.RELEASE</version> <optional>true</optional> </dependency> <dependency> <!-- for Spring RestTemplate in unit tests --> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.10.2</version> + <version>2.11.1</version> <scope>test</scope> </dependency> <!-- Dépendance optionnelle google guice (aop) --> <dependency> <groupId>com.google.inject</groupId> <artifactId>guice</artifactId> - <version>4.2.2</version> + <version>4.2.3</version> <optional>true</optional> </dependency> <!-- Dépendance optionnelle xwork pour interceptor struts 2 --> @@ -295,7 +295,7 @@ <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> - <version>4.1</version> + <version>4.2</version> <!-- Utilisée uniquement pour l'exécution des tests unitaires --> <scope>test</scope> </dependency> @@ -303,7 +303,7 @@ <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa</artifactId> - <version>3.1.0</version> + <version>3.1.1</version> <!-- Utilisée uniquement pour l'exécution des tests unitaires --> <scope>test</scope> </dependency> diff --git a/javamelody-swing/pom.xml b/javamelody-swing/pom.xml index e23c075b5..7449599dc 100644 --- a/javamelody-swing/pom.xml +++ b/javamelody-swing/pom.xml @@ -105,7 +105,7 @@ <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> - <version>1.4.11.1</version> + <version>1.4.12</version> </dependency> </dependencies> diff --git a/javamelody-test-webapp/pom.xml b/javamelody-test-webapp/pom.xml index ad5f48177..8e9baa03b 100644 --- a/javamelody-test-webapp/pom.xml +++ b/javamelody-test-webapp/pom.xml @@ -28,7 +28,7 @@ <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> - <version>8.0.19</version> + <version>8.0.20</version> </dependency> <dependency> <groupId>javax.servlet</groupId> @@ -67,7 +67,7 @@ <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> - <version>2.13.0</version> + <version>2.13.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> @@ -119,7 +119,7 @@ <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> - <version>1.4.11.1</version> + <version>1.4.12</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> @@ -158,33 +158,33 @@ <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> - <version>5.2.3.RELEASE</version> + <version>5.2.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> - <version>5.2.3.RELEASE</version> + <version>5.2.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> - <version>5.2.3.RELEASE</version> + <version>5.2.7.RELEASE</version> </dependency> <dependency> <!-- for Spring RestTemplate in unit tests --> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.10.2</version> + <version>2.11.1</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> - <version>2.2.4.RELEASE</version> + <version>3.0.1.RELEASE</version> </dependency> <dependency> <groupId>com.google.inject</groupId> <artifactId>guice</artifactId> - <version>4.2.2</version> + <version>4.2.3</version> </dependency> <!-- Dépendance xwork pour interceptor struts 2 --> <dependency> @@ -200,7 +200,7 @@ <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa</artifactId> - <version>3.1.0</version> + <version>3.1.1</version> <scope>provided</scope> </dependency> <dependency> @@ -222,7 +222,7 @@ <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> - <version>4.1</version> + <version>4.2</version> <scope>compile</scope> </dependency> </dependencies>
0
6a7cc8ff85827fa9ac715b3a83c2d9147f33cd43?w=1
https://github.com/php/php-src/commit/6a7cc8ff85827fa9ac715b3a83c2d9147f33cd43?w=1
Fix bug #73052 - Memory Corruption in During Deserialized-object Destruction
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 56c47b7f84ec6..cdc0b69fbf290 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -215,7 +215,7 @@ ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle, } zend_end_try(); } } - + /* re-read the object from the object store as the store might have been reallocated in the dtor */ obj = &EG(objects_store).object_buckets[handle].bucket.obj; @@ -306,8 +306,8 @@ ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC) { zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); zend_object_store_bucket *obj_bucket = &EG(objects_store).object_buckets[handle]; - - obj_bucket->bucket.obj.handlers = Z_OBJ_HT_P(zobject);; + + obj_bucket->bucket.obj.handlers = Z_OBJ_HT_P(zobject); obj_bucket->destructor_called = 1; } diff --git a/ext/standard/tests/serialize/bug73052.phpt b/ext/standard/tests/serialize/bug73052.phpt new file mode 100644 index 0000000000000..63b484bf14d25 --- /dev/null +++ b/ext/standard/tests/serialize/bug73052.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #73052: Memory Corruption in During Deserialized-object Destruction +--FILE-- +<?php + +class obj { + var $ryat; + public function __destruct() { + $this->ryat = null; + } +} + +$poc = 'O:3:"obj":1:{'; +var_dump(unserialize($poc)); +?> +--EXPECTF-- +Notice: unserialize(): Error at offset 13 of 13 bytes in %sbug73052.php on line %d +bool(false) diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index c8e6f8a0ca9aa..549149267eb2f 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -437,6 +437,7 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) /* We've got partially constructed object on our hands here. Wipe it. */ if(Z_TYPE_PP(rval) == IS_OBJECT) { zend_hash_clean(Z_OBJPROP_PP(rval)); + zend_object_store_ctor_failed(*rval TSRMLS_CC); } ZVAL_NULL(*rval); return 0; @@ -491,7 +492,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 495 "ext/standard/var_unserializer.c" +#line 496 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -551,9 +552,9 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 860 "ext/standard/var_unserializer.re" +#line 861 "ext/standard/var_unserializer.re" { return 0; } -#line 557 "ext/standard/var_unserializer.c" +#line 558 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -596,13 +597,13 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) goto yy3; yy14: ++YYCURSOR; -#line 854 "ext/standard/var_unserializer.re" +#line 855 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 606 "ext/standard/var_unserializer.c" +#line 607 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -633,7 +634,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 707 "ext/standard/var_unserializer.re" +#line 708 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -780,7 +781,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 784 "ext/standard/var_unserializer.c" +#line 785 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -805,7 +806,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 698 "ext/standard/var_unserializer.re" +#line 699 "ext/standard/var_unserializer.re" { if (!var_hash) return 0; @@ -814,7 +815,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 818 "ext/standard/var_unserializer.c" +#line 819 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -835,7 +836,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 677 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -856,7 +857,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 860 "ext/standard/var_unserializer.c" +#line 861 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -877,7 +878,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 642 "ext/standard/var_unserializer.re" +#line 643 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -912,7 +913,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 916 "ext/standard/var_unserializer.c" +#line 917 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -933,7 +934,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 609 "ext/standard/var_unserializer.re" +#line 610 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -966,7 +967,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 970 "ext/standard/var_unserializer.c" +#line 971 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1054,7 +1055,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } yy63: ++YYCURSOR; -#line 599 "ext/standard/var_unserializer.re" +#line 600 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1064,7 +1065,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1068 "ext/standard/var_unserializer.c" +#line 1069 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1123,7 +1124,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 584 "ext/standard/var_unserializer.re" +#line 585 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1138,7 +1139,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return 1; } -#line 1142 "ext/standard/var_unserializer.c" +#line 1143 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1165,7 +1166,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 557 "ext/standard/var_unserializer.re" +#line 558 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1192,7 +1193,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1196 "ext/standard/var_unserializer.c" +#line 1197 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1200,24 +1201,24 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 550 "ext/standard/var_unserializer.re" +#line 551 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1211 "ext/standard/var_unserializer.c" +#line 1212 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 543 "ext/standard/var_unserializer.re" +#line 544 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1221 "ext/standard/var_unserializer.c" +#line 1222 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1240,7 +1241,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 520 "ext/standard/var_unserializer.re" +#line 521 "ext/standard/var_unserializer.re" { long id; @@ -1263,7 +1264,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return 1; } -#line 1267 "ext/standard/var_unserializer.c" +#line 1268 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1286,7 +1287,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 499 "ext/standard/var_unserializer.re" +#line 500 "ext/standard/var_unserializer.re" { long id; @@ -1307,9 +1308,9 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return 1; } -#line 1311 "ext/standard/var_unserializer.c" +#line 1312 "ext/standard/var_unserializer.c" } -#line 862 "ext/standard/var_unserializer.re" +#line 863 "ext/standard/var_unserializer.re" return 0; diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 11b93c522b226..ce84bf5eb40cc 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -441,6 +441,7 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) /* We've got partially constructed object on our hands here. Wipe it. */ if(Z_TYPE_PP(rval) == IS_OBJECT) { zend_hash_clean(Z_OBJPROP_PP(rval)); + zend_object_store_ctor_failed(*rval TSRMLS_CC); } ZVAL_NULL(*rval); return 0;
1
ef647a2acf2363c6018e8543d665ac8862593372
https://github.com/pivotal-cf/spring-cloud-sso-connector/commit/ef647a2acf2363c6018e8543d665ac8862593372
Revert commit c594317337457a7f19166244f6acc66b476be856 * Above commit creates a regression for when we make the Issuer check without binding to a SSO service [#157069100] Signed-off-by: Alex Jackson <[email protected]>
diff --git a/src/main/java/io/pivotal/spring/cloud/IssuerCheckConfiguration.java b/src/main/java/io/pivotal/spring/cloud/IssuerCheckConfiguration.java index caccbac..985dbfe 100644 --- a/src/main/java/io/pivotal/spring/cloud/IssuerCheckConfiguration.java +++ b/src/main/java/io/pivotal/spring/cloud/IssuerCheckConfiguration.java @@ -13,7 +13,7 @@ import java.net.MalformedURLException; @Configuration -@ConditionalOnProperty({"sso.connector.cloud.available"}) +@ConditionalOnProperty({"ssoServiceUrl", "security.oauth2.resource.jwk.key-set-uri"}) public class IssuerCheckConfiguration { @Value("${ssoServiceUrl}") private String ssoServiceUrl; diff --git a/src/main/java/io/pivotal/spring/cloud/SsoServiceCredentialsListener.java b/src/main/java/io/pivotal/spring/cloud/SsoServiceCredentialsListener.java index c101bed..a4bebcc 100644 --- a/src/main/java/io/pivotal/spring/cloud/SsoServiceCredentialsListener.java +++ b/src/main/java/io/pivotal/spring/cloud/SsoServiceCredentialsListener.java @@ -35,7 +35,6 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { map.put("security.oauth2.resource.userInfoUri", ssoServiceInfo.getAuthDomain() + "/userinfo"); map.put("security.oauth2.resource.tokenInfoUri", ssoServiceInfo.getAuthDomain() + "/check_token"); map.put("security.oauth2.resource.jwk.key-set-uri", ssoServiceInfo.getAuthDomain() + "/token_keys"); - map.put("sso.connector.cloud.available", "success"); MapPropertySource mapPropertySource = new MapPropertySource("vcapPivotalSso", map); event.getEnvironment().getPropertySources().addFirst(mapPropertySource); diff --git a/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationLocalTest.java b/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationLocalTest.java index b30724b..45907a8 100644 --- a/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationLocalTest.java +++ b/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationLocalTest.java @@ -27,7 +27,5 @@ public void testJwkTokenStoreNotFoundInContext() { thrown.expectMessage("No qualifying bean of type 'org.springframework.security.oauth2.provider.token.TokenStore' available"); applicationContext.getBean( TokenStore.class ); - } - } diff --git a/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationTest.java b/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationTest.java index 95b4626..d34b5d0 100644 --- a/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationTest.java +++ b/src/test/java/io/pivotal/spring/cloud/IssuerCheckConfigurationTest.java @@ -19,8 +19,7 @@ @EnableAutoConfiguration @TestPropertySource(properties = { "ssoServiceUrl=https://cf-identity-eng-test1.login.run.pivotal.io", - "security.oauth2.resource.jwk.key-set-uri=https://cf-identity-eng-test1.login.run.pivotal.io/token_keys", - "sso.connector.cloud.available=success" + "security.oauth2.resource.jwk.key-set-uri=https://cf-identity-eng-test1.login.run.pivotal.io/token_keys" }) public class IssuerCheckConfigurationTest { @ClassRule diff --git a/src/test/java/io/pivotal/spring/cloud/SsoServiceCredentialsListenerTest.java b/src/test/java/io/pivotal/spring/cloud/SsoServiceCredentialsListenerTest.java index 6050520..dd4f78b 100644 --- a/src/test/java/io/pivotal/spring/cloud/SsoServiceCredentialsListenerTest.java +++ b/src/test/java/io/pivotal/spring/cloud/SsoServiceCredentialsListenerTest.java @@ -48,6 +48,5 @@ public void addClientCredentials() { assertEquals("test-auth-domain/userinfo", environment.getProperty("security.oauth2.resource.userInfoUri")); assertEquals("test-auth-domain/check_token", environment.getProperty("security.oauth2.resource.tokenInfoUri")); assertEquals("test-auth-domain", environment.getProperty("ssoServiceUrl")); - assertEquals("success", environment.getProperty("sso.connector.cloud.available")); } }
0
f5ae2b821c22ebe0c96f3516d4e90f4255633828
https://github.com/phaag/nfdump/commit/f5ae2b821c22ebe0c96f3516d4e90f4255633828
Re-address issue #231 - remove strict rule rfc 7011
diff --git a/ChangeLog b/ChangeLog index a0b2b67..8b92e58 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2020-08-02 +- Re-address issue #231 - remove strict rule rfc 7011 + 2020-08-02 - Release 1.6.21 - Address issue #159. Implement rfc 7011 and include sender UDP port into unique template identification diff --git a/bin/ipfix.c b/bin/ipfix.c index a730a8b..19c9d63 100644 --- a/bin/ipfix.c +++ b/bin/ipfix.c @@ -158,7 +158,6 @@ typedef struct exporterDomain_s { // exporter information exporter_info_record_t info; - in_port_t port; // follow rfc 7011 - matching src port uint64_t packets; // number of packets sent by this exporter uint64_t flows; // number of flow records sent by this exporter @@ -383,7 +382,6 @@ uint32_t ObservationDomain = ntohl(ipfix_header->ObservationDomain); while ( *e ) { if ( (*e)->info.id == ObservationDomain && (*e)->info.version == 10 && - (*e)->port == fs->port && (*e)->info.ip.V6[0] == fs->ip.V6[0] && (*e)->info.ip.V6[1] == fs->ip.V6[1]) return *e; e = &((*e)->next); @@ -412,7 +410,6 @@ uint32_t ObservationDomain = ntohl(ipfix_header->ObservationDomain); (*e)->info.header.size = sizeof(exporter_info_record_t); (*e)->info.id = ObservationDomain; (*e)->info.ip = fs->ip; - (*e)->port = fs->port; (*e)->info.sa_family = fs->sa_family; (*e)->info.version = 10; (*e)->info.sysid = 0;
0
17b34397019372eeb58192f1abeecbfd3c99c128
https://github.com/libguestfs/hivex/commit/17b34397019372eeb58192f1abeecbfd3c99c128
Ignore config.cache file.
diff --git a/.gitignore b/.gitignore index fe22bdc..658f65c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ Makefile.in /build-aux /ChangeLog /compile +/config.cache /config.guess /config.h /config.h.in
0
00ea64d1d4c47fdc796f3401280ab66612d6ca3b
https://github.com/keycloak/keycloak/commit/00ea64d1d4c47fdc796f3401280ab66612d6ca3b
KEYCLOAK-16143 Honor AuthenticationProcessor.forwardedErrorMessage when rendering registration form
diff --git a/services/src/main/java/org/keycloak/authentication/FormAuthenticationFlow.java b/services/src/main/java/org/keycloak/authentication/FormAuthenticationFlow.java index b54d481fcdb..5c7c167a67e 100755 --- a/services/src/main/java/org/keycloak/authentication/FormAuthenticationFlow.java +++ b/services/src/main/java/org/keycloak/authentication/FormAuthenticationFlow.java @@ -36,6 +36,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.net.URI; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -276,7 +277,11 @@ public URI getActionUrl(String executionId, String code) { @Override public Response processFlow() { - return renderForm(null, null); + + // KEYCLOAK-16143: Propagate forwarded error messages if present + List<FormMessage> errors = processor.forwardedErrorMessage != null ? Collections.singletonList(processor.forwardedErrorMessage) : null; + + return renderForm(null, errors); } public Response renderForm(MultivaluedMap<String, String> formData, List<FormMessage> errors) {
0
be9972bddde2806166875a7ad1fda3c5a514b4a7
https://github.com/OTRS/FAQ/commit/be9972bddde2806166875a7ad1fda3c5a514b4a7
Prepared for release.
diff --git a/CHANGES-FAQ.md b/CHANGES-FAQ.md index 055eb251..0d4d67d4 100644 --- a/CHANGES-FAQ.md +++ b/CHANGES-FAQ.md @@ -1,4 +1,6 @@ -#6.0.12 2018-??-?? +#6.0.13 2018-??-?? + +#6.0.12 2018-11-09 - 2018-11-05 Updated translations, thanks to all translators. - 2018-10-23 Fixed bug#[13871](https://bugs.otrs.org/show_bug.cgi?id=13871) - After deleting image from the FAQ article, it's still stored in the DB.
0
30e7feb7e591388fb639c2113f4f6b96f596cdd9
https://github.com/mybb/mybb/commit/30e7feb7e591388fb639c2113f4f6b96f596cdd9
Merge pull request #4203 from effone/force-download Force Download Attachments
diff --git a/admin/modules/config/attachment_types.php b/admin/modules/config/attachment_types.php index 043f2f6a84..6857375c8d 100644 --- a/admin/modules/config/attachment_types.php +++ b/admin/modules/config/attachment_types.php @@ -89,6 +89,7 @@ "maxsize" => $maxsize, "icon" => $db->escape_string($mybb->input['icon']), 'enabled' => $mybb->get_input('enabled', MyBB::INPUT_INT), + 'forcedownload' => $mybb->get_input('forcedownload', MyBB::INPUT_INT), 'groups' => $db->escape_string($mybb->get_input('groups')), 'forums' => $db->escape_string($mybb->get_input('forums')), 'avatarfile' => $mybb->get_input('avatarfile', MyBB::INPUT_INT) @@ -278,6 +279,8 @@ <script type=\"text/javascript\"> checkAction('forums'); </script>"; + + $mybb->input['forcedownload'] = $mybb->get_input('forcedownload', MyBB::INPUT_INT); $form_container = new FormContainer($lang->add_new_attachment_type); $form_container->output_row($lang->name, $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name'); @@ -286,6 +289,7 @@ $form_container->output_row($lang->maximum_file_size, $lang->maximum_file_size_desc.$limit_string, $form->generate_numeric_field('maxsize', $mybb->input['maxsize'], array('id' => 'maxsize', 'min' => 0)), 'maxsize'); $form_container->output_row($lang->attachment_icon, $lang->attachment_icon_desc, $form->generate_text_box('icon', $mybb->input['icon'], array('id' => 'icon')), 'icon'); $form_container->output_row($lang->enabled, '', $form->generate_yes_no_radio('enabled', $mybb->input['enabled']), 'enabled'); + $form_container->output_row($lang->forcedownload, $lang->forcedownload_desc, $form->generate_yes_no_radio('forcedownload', $mybb->input['forcedownload']), 'forcedownload'); $form_container->output_row($lang->available_to_groups, '', $groups_select_code, '', array(), array('id' => 'row_groups')); $form_container->output_row($lang->available_in_forums, '', $forums_select_code, '', array(), array('id' => 'row_forums')); $form_container->output_row($lang->avatar_file, $lang->avatar_file_desc, $form->generate_yes_no_radio('avatarfile', $mybb->input['avatarfile']), 'avatarfile'); @@ -373,6 +377,7 @@ "maxsize" => $mybb->get_input('maxsize', MyBB::INPUT_INT), "icon" => $db->escape_string($mybb->input['icon']), 'enabled' => $mybb->get_input('enabled', MyBB::INPUT_INT), + 'forcedownload' => $mybb->get_input('forcedownload', MyBB::INPUT_INT), 'groups' => $db->escape_string($mybb->get_input('groups')), 'forums' => $db->escape_string($mybb->get_input('forums')), 'avatarfile' => $mybb->get_input('avatarfile', MyBB::INPUT_INT) @@ -557,6 +562,8 @@ checkAction('forums'); </script>"; + $mybb->input['forcedownload'] = $mybb->get_input('forcedownload', MyBB::INPUT_INT); + $form_container = new FormContainer($lang->edit_attachment_type); $form_container->output_row($lang->name, $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name'); $form_container->output_row($lang->file_extension." <em>*</em>", $lang->file_extension_desc, $form->generate_text_box('extension', $mybb->input['extension'], array('id' => 'extension')), 'extension'); @@ -564,6 +571,7 @@ $form_container->output_row($lang->maximum_file_size, $lang->maximum_file_size_desc.$limit_string, $form->generate_numeric_field('maxsize', $mybb->input['maxsize'], array('id' => 'maxsize', 'min' => 0)), 'maxsize'); $form_container->output_row($lang->attachment_icon, $lang->attachment_icon_desc, $form->generate_text_box('icon', $mybb->input['icon'], array('id' => 'icon')), 'icon'); $form_container->output_row($lang->enabled, '', $form->generate_yes_no_radio('enabled', $mybb->input['enabled']), 'enabled'); + $form_container->output_row($lang->forcedownload, $lang->forcedownload_desc, $form->generate_yes_no_radio('forcedownload', $mybb->input['forcedownload']), 'forcedownload'); $form_container->output_row($lang->available_to_groups, '', $groups_select_code, '', array(), array('id' => 'row_groups')); $form_container->output_row($lang->available_in_forums, '', $forums_select_code, '', array(), array('id' => 'row_forums')); $form_container->output_row($lang->avatar_file, $lang->avatar_file_desc, $form->generate_yes_no_radio('avatarfile', $mybb->input['avatarfile']), 'avatarfile'); diff --git a/attachment.php b/attachment.php index b4d0e2df1d..2f65a73ca4 100644 --- a/attachment.php +++ b/attachment.php @@ -181,7 +181,14 @@ case "image/png": case "text/plain": header("Content-type: {$attachment['filetype']}"); - $disposition = "inline"; + if($attachtypes[$ext]['forcedownload']) + { + $disposition = "attachment"; + } + else + { + $disposition = "inline"; + } break; default: diff --git a/inc/languages/english/admin/config_attachment_types.lang.php b/inc/languages/english/admin/config_attachment_types.lang.php index 94e3c85676..5b4ea9095d 100644 --- a/inc/languages/english/admin/config_attachment_types.lang.php +++ b/inc/languages/english/admin/config_attachment_types.lang.php @@ -46,6 +46,8 @@ $l['success_deactivated_attachment_type'] = 'The selected attachment type has been deactivated successfully.'; $l['enabled'] = "Enabled?"; +$l['forcedownload'] = "Force Download"; +$l['forcedownload_desc'] = "Enabling this will always force the attachment to be downloaded as a file."; $l['avatar_file'] = 'Avatar File'; $l['avatar_file_desc'] = 'Do you want to allow this attachment type to be used for avatars?'; diff --git a/install/resources/upgrade52.php b/install/resources/upgrade52.php index e1c9dccda9..3103a28b30 100644 --- a/install/resources/upgrade52.php +++ b/install/resources/upgrade52.php @@ -31,13 +31,15 @@ function upgrade51_dbchanges() switch($db->type) { - // Add new setting for new usergroup permission if group members can hide online status + // Add new settings for (a) new usergroup permission if group members can hide online status & (b) attachments force download case "pgsql": $db->add_column("usergroups", "canbeinvisible", "smallint NOT NULL default '1' AFTER canusercp"); + $db->add_column("attachtypes", "forcedownload", "smallint NOT NULL default '0' AFTER enabled"); break; default: $db->add_column("usergroups", "canbeinvisible", "tinyint(1) NOT NULL default '1' AFTER canusercp"); + $db->add_column("attachtypes", "forcedownload", "tinyint(1) NOT NULL default '0' AFTER enabled"); break; } -} \ No newline at end of file +}
0
5dc2e3531babcbdc165884d1a47cbcd13455522d
https://github.com/josh/rails/commit/5dc2e3531babcbdc165884d1a47cbcd13455522d
stop calling to_sym when building arel nodes [CVE-2013-1854]
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index bd783a94cf431..f44d46d15b19a 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -48,7 +48,7 @@ def self.expand(klass, table, column, value) column = reflection.foreign_key end - queries << build(table[column.to_sym], value) + queries << build(table[column], value) queries end diff --git a/activerecord/test/cases/relation/where_chain_test.rb b/activerecord/test/cases/relation/where_chain_test.rb index 8ce44636b468f..92d1e013e8a47 100644 --- a/activerecord/test/cases/relation/where_chain_test.rb +++ b/activerecord/test/cases/relation/where_chain_test.rb @@ -6,26 +6,31 @@ module ActiveRecord class WhereChainTest < ActiveRecord::TestCase fixtures :posts + def setup + super + @name = 'title' + end + def test_not_eq - expected = Arel::Nodes::NotEqual.new(Post.arel_table[:title], 'hello') + expected = Arel::Nodes::NotEqual.new(Post.arel_table[@name], 'hello') relation = Post.where.not(title: 'hello') assert_equal([expected], relation.where_values) end def test_not_null - expected = Arel::Nodes::NotEqual.new(Post.arel_table[:title], nil) + expected = Arel::Nodes::NotEqual.new(Post.arel_table[@name], nil) relation = Post.where.not(title: nil) assert_equal([expected], relation.where_values) end def test_not_in - expected = Arel::Nodes::NotIn.new(Post.arel_table[:title], %w[hello goodbye]) + expected = Arel::Nodes::NotIn.new(Post.arel_table[@name], %w[hello goodbye]) relation = Post.where.not(title: %w[hello goodbye]) assert_equal([expected], relation.where_values) end def test_association_not_eq - expected = Arel::Nodes::NotEqual.new(Comment.arel_table[:title], 'hello') + expected = Arel::Nodes::NotEqual.new(Comment.arel_table[@name], 'hello') relation = Post.joins(:comments).where.not(comments: {title: 'hello'}) assert_equal(expected.to_sql, relation.where_values.first.to_sql) end @@ -33,20 +38,20 @@ def test_association_not_eq def test_not_eq_with_preceding_where relation = Post.where(title: 'hello').where.not(title: 'world') - expected = Arel::Nodes::Equality.new(Post.arel_table[:title], 'hello') + expected = Arel::Nodes::Equality.new(Post.arel_table[@name], 'hello') assert_equal(expected, relation.where_values.first) - expected = Arel::Nodes::NotEqual.new(Post.arel_table[:title], 'world') + expected = Arel::Nodes::NotEqual.new(Post.arel_table[@name], 'world') assert_equal(expected, relation.where_values.last) end def test_not_eq_with_succeeding_where relation = Post.where.not(title: 'hello').where(title: 'world') - expected = Arel::Nodes::NotEqual.new(Post.arel_table[:title], 'hello') + expected = Arel::Nodes::NotEqual.new(Post.arel_table[@name], 'hello') assert_equal(expected, relation.where_values.first) - expected = Arel::Nodes::Equality.new(Post.arel_table[:title], 'world') + expected = Arel::Nodes::Equality.new(Post.arel_table[@name], 'world') assert_equal(expected, relation.where_values.last) end @@ -65,10 +70,10 @@ def test_not_eq_with_array_parameter def test_chaining_multiple relation = Post.where.not(author_id: [1, 2]).where.not(title: 'ruby on rails') - expected = Arel::Nodes::NotIn.new(Post.arel_table[:author_id], [1, 2]) + expected = Arel::Nodes::NotIn.new(Post.arel_table['author_id'], [1, 2]) assert_equal(expected, relation.where_values[0]) - expected = Arel::Nodes::NotEqual.new(Post.arel_table[:title], 'ruby on rails') + expected = Arel::Nodes::NotEqual.new(Post.arel_table[@name], 'ruby on rails') assert_equal(expected, relation.where_values[1]) end end
1
5862696d3df057572c404fb8874409656afd2a37
https://github.com/markevans/dragonfly/commit/5862696d3df057572c404fb8874409656afd2a37
Move Message Expectations Up
diff --git a/spec/dragonfly_spec.rb b/spec/dragonfly_spec.rb index 8beb9630..a5e75ed4 100644 --- a/spec/dragonfly_spec.rb +++ b/spec/dragonfly_spec.rb @@ -35,23 +35,21 @@ context "logger is nil" do before do + allow_message_expectations_on_nil Dragonfly.logger = nil end it "does not call debug" do - allow_message_expectations_on_nil Dragonfly.logger.should_not_receive(:debug) Dragonfly.debug("something") end it "does not warn" do - allow_message_expectations_on_nil Dragonfly.logger.should_not_receive(:warn) Dragonfly.warn("something") end it "does not show info" do - allow_message_expectations_on_nil Dragonfly.logger.should_not_receive(:info) Dragonfly.info("something") end
0
2281b1f365c50ee1a470fb9990b753eadee9095
https://github.com/apache/camel/commit/2281b1f365c50ee1a470fb9990b753eadee9095
CAMEL-6748: Optimize File Producers by Skipping Header Evaluation. Thansk to James Carman for the patch.
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java index af9d0db29b2c..aec0a75165bb 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java @@ -286,30 +286,41 @@ public String createFileName(Exchange exchange) { String answer; // overrule takes precedence - String overrule = exchange.getIn().getHeader(Exchange.OVERRULE_FILE_NAME, String.class); - String consumed = exchange.getIn().getHeader(Exchange.FILE_NAME_CONSUMED, String.class); - String name = overrule == null ? exchange.getIn().getHeader(Exchange.FILE_NAME, String.class) : overrule; + Object value; + + Object overrule = exchange.getIn().getHeader(Exchange.OVERRULE_FILE_NAME); + if (overrule != null) { + if (overrule instanceof Expression) { + value = overrule; + } else { + value = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, overrule); + } + } else { + value = exchange.getIn().getHeader(Exchange.FILE_NAME); + } // if we have an overrule then override the existing header to use the overrule computed name from this point forward if (overrule != null) { - exchange.getIn().setHeader(Exchange.FILE_NAME, name); + exchange.getIn().setHeader(Exchange.FILE_NAME, value); + } + + if (value != null && value instanceof String && StringHelper.hasStartToken((String) value, "simple")) { + log.warn("Simple expression: {} detected in header: {} of type String. This feature has been removed (see CAMEL-6748).", value, Exchange.FILE_NAME); } // expression support Expression expression = endpoint.getFileName(); - - if (name != null && !name.equals(consumed)) { - // the header name can be an expression too, that should override - // whatever configured on the endpoint - if (StringHelper.hasStartToken(name, "simple")) { - log.trace("{} contains a Simple expression: {}", Exchange.FILE_NAME, name); - Language language = getEndpoint().getCamelContext().resolveLanguage("file"); - expression = language.createExpression(name); - } + if (value != null && value instanceof Expression) { + expression = (Expression) value; } + + // evaluate the name as a String from the value + String name; if (expression != null) { log.trace("Filename evaluated as expression: {}", expression); name = expression.evaluate(exchange, String.class); + } else { + name = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, value); } // flatten name diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java index c6a83d2d6a36..0ddc4121344a 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java @@ -22,6 +22,8 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; +import static org.apache.camel.language.simple.SimpleLanguage.simple; + /** * Unit test for expression option for file consumer. */ @@ -70,7 +72,7 @@ public void configure() throws Exception { public void testConsumeFileBasedOnDatePattern() throws Exception { template.sendBodyAndHeader("file://target/filelanguage/date", "Bye World", Exchange.FILE_NAME, "myfile-20081128.txt"); template.sendBodyAndHeader("file://target/filelanguage/date", "Hello World", Exchange.FILE_NAME, "myfile-20081129.txt"); - template.sendBodyAndHeader("file://target/filelanguage/date", "Goodday World", Exchange.FILE_NAME, "myfile-${date:now:yyyyMMdd}.txt"); + template.sendBodyAndHeader("file://target/filelanguage/date", "Goodday World", Exchange.FILE_NAME, simple("myfile-${date:now:yyyyMMdd}.txt")); context.addRoutes(new RouteBuilder() { @Override diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerConsumedFileNameEvaluationTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerConsumedFileNameEvaluationTest.java deleted file mode 100644 index 64da59d0054a..000000000000 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerConsumedFileNameEvaluationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.file; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; - -/** - * @version - */ -public class FileProducerConsumedFileNameEvaluationTest extends ContextTestSupport { - - @Override - protected void setUp() throws Exception { - deleteDirectory("target/producerconsumedfilename"); - super.setUp(); - } - - public void testFileNameNotEvaluatedWhenMatchingConsumed() throws Exception { - Map<String, Object> headers = new TreeMap<String, Object>(); - headers.put(Exchange.FILE_NAME, "file-${date:now:yyyyMMdd}"); - headers.put(Exchange.FILE_NAME_CONSUMED, "file-${date:now:yyyyMMdd}"); - template.sendBodyAndHeaders("file://target/producerconsumedfilename", "Hello World", headers); - assertFileExists("target/producerconsumedfilename/file-${date:now:yyyyMMdd}"); - } - - public void testFileNameEvaluatedWhenNotMatchingConsumed() throws Exception { - Map<String, Object> headers = new TreeMap<String, Object>(); - headers.put(Exchange.FILE_NAME, "file-${date:now:yyyyMMdd}.txt"); - headers.put(Exchange.FILE_NAME_CONSUMED, "file-consumed"); - template.sendBodyAndHeaders("file://target/producerconsumedfilename", "Hello World", headers); - String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); - assertFileExists("target/producerconsumedfilename/file-" + date + ".txt"); - } - - public void testFileNameEvaluatedWhenConsumedNull() throws Exception { - Map<String, Object> headers = new TreeMap<String, Object>(); - headers.put(Exchange.FILE_NAME, "file-${date:now:yyyyMMdd}.txt"); - template.sendBodyAndHeaders("file://target/producerconsumedfilename", "Hello World", headers); - String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); - assertFileExists("target/producerconsumedfilename/file-" + date + ".txt"); - } -} diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java index 01813e06b376..0eb15be06253 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java @@ -24,6 +24,8 @@ import org.apache.camel.Exchange; import org.apache.camel.impl.JndiRegistry; +import static org.apache.camel.language.simple.SimpleLanguage.simple; + /** * Unit test for expression option for file producer. */ @@ -42,11 +44,9 @@ protected JndiRegistry createRegistry() throws Exception { return jndi; } - public void testProduceBeanByHeader() throws Exception { - template.sendBodyAndHeader("file://target/filelanguage", "Hello World", - Exchange.FILE_NAME, "${bean:myguidgenerator}.bak"); - - assertFileExists("target/filelanguage/123.bak"); + public void testProducerFileNameHeaderNotEvaluated() { + template.sendBodyAndHeader("file://target/filelanguage", "Hello World", Exchange.FILE_NAME, "$simple{myfile-${date:now:yyyyMMdd}}.txt"); + assertFileExists("target/filelanguage/$simple{myfile-${date:now:yyyyMMdd}}.txt"); } public void testProduceBeanByExpression() throws Exception { @@ -57,7 +57,7 @@ public void testProduceBeanByExpression() throws Exception { public void testProducerDateByHeader() throws Exception { template.sendBodyAndHeader("file://target/filelanguage", "Hello World", - Exchange.FILE_NAME, "myfile-${date:now:yyyyMMdd}.txt"); + Exchange.FILE_NAME, simple("myfile-${date:now:yyyyMMdd}.txt")); String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); assertFileExists("target/filelanguage/myfile-" + date + ".txt"); diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java index 7df7a9296b1e..308c0416d692 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java @@ -32,6 +32,8 @@ import org.junit.After; import org.junit.Before; +import static org.apache.camel.language.simple.SimpleLanguage.simple; + /** * Base class for unit testing using a FTPServer */ @@ -125,7 +127,7 @@ protected FtpServerFactory createFtpServerFactory() throws Exception { } public void sendFile(String url, Object body, String fileName) { - template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, fileName); + template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, simple(fileName)); } }
1
7df3830c81716b959a2d0d3a0d8216b860ae0dc7
https://github.com/Piwigo/Piwigo/commit/7df3830c81716b959a2d0d3a0d8216b860ae0dc7
fixes #575, sanitize user input before display on die()
diff --git a/admin/plugin.php b/admin/plugin.php index 68e0c50d7a..16de979a52 100644 --- a/admin/plugin.php +++ b/admin/plugin.php @@ -63,6 +63,6 @@ } else { - die('Missing file '.$filename); + die('Missing file '.htmlentities($filename)); } ?> \ No newline at end of file
1
2c13e97d656c1c0ac4d76eb9d307664aae0e0cf7
https://github.com/wireshark/wireshark/commit/2c13e97d656c1c0ac4d76eb9d307664aae0e0cf7
The WTAP_ENCAP_ETHERNET dissector needs to be passed a struct eth_phdr. We now require that. Make it so. Bug: 12440 Change-Id: Iffee520976b013800699bde3c6092a3e86be0d76 Reviewed-on: https://code.wireshark.org/review/15424 Reviewed-by: Guy Harris <[email protected]>
diff --git a/epan/dissectors/packet-pktap.c b/epan/dissectors/packet-pktap.c index 6825cdb6298..59a6d4c00f0 100644 --- a/epan/dissectors/packet-pktap.c +++ b/epan/dissectors/packet-pktap.c @@ -135,6 +135,9 @@ dissect_pktap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvbuff_t *next_tvb; int offset = 0; guint32 pkt_len, rectype, dlt; + int wtap_encap; + struct eth_phdr eth; + void *phdr; col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKTAP"); col_clear(pinfo->cinfo, COL_INFO); @@ -202,8 +205,20 @@ dissect_pktap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (rectype == PKT_REC_PACKET) { next_tvb = tvb_new_subset_remaining(tvb, pkt_len); - dissector_try_uint(wtap_encap_dissector_table, - wtap_pcap_encap_to_wtap_encap(dlt), next_tvb, pinfo, tree); + wtap_encap = wtap_pcap_encap_to_wtap_encap(dlt); + switch (wtap_encap) { + + case WTAP_ENCAP_ETHERNET: + eth.fcs_len = -1; /* Unknown whether we have an FCS */ + phdr = &eth; + break; + + default: + phdr = NULL; + break; + } + dissector_try_uint_new(wtap_encap_dissector_table, + wtap_encap, next_tvb, pinfo, tree, TRUE, phdr); } } diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c index 95693ca5e39..c8eb503adff 100644 --- a/epan/dissectors/packet-ppi.c +++ b/epan/dissectors/packet-ppi.c @@ -857,6 +857,9 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint last_frame = 0; gint len_remain, /*pad_len = 0,*/ ampdu_len = 0; struct ieee_802_11_phdr phdr; + int wtap_encap; + struct eth_phdr eth; + void *phdrp; col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPI"); col_clear(pinfo->cinfo, COL_INFO); @@ -1137,8 +1140,20 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) call_dissector_with_data(ieee80211_radio_handle, next_tvb, pinfo, tree, &phdr); } else { /* Everything else. This will pass a NULL data argument. */ - dissector_try_uint(wtap_encap_dissector_table, - wtap_pcap_encap_to_wtap_encap(dlt), next_tvb, pinfo, tree); + wtap_encap = wtap_pcap_encap_to_wtap_encap(dlt); + switch (wtap_encap) { + + case WTAP_ENCAP_ETHERNET: + eth.fcs_len = -1; /* Unknown whether we have an FCS */ + phdrp = &eth; + break; + + default: + phdrp = NULL; + break; + } + dissector_try_uint_new(wtap_encap_dissector_table, + wtap_encap, next_tvb, pinfo, tree, TRUE, phdrp); } } diff --git a/epan/dissectors/packet-rpcap.c b/epan/dissectors/packet-rpcap.c index 46a2e62c8b5..673421a9fd3 100644 --- a/epan/dissectors/packet-rpcap.c +++ b/epan/dissectors/packet-rpcap.c @@ -838,6 +838,8 @@ dissect_rpcap_packet (tvbuff_t *tvb, packet_info *pinfo, proto_tree *top_tree, tvbuff_t *new_tvb; guint caplen, len, frame_no; gint reported_length_remaining; + struct eth_phdr eth; + void *phdr; ti = proto_tree_add_item (parent_tree, hf_packet, tvb, offset, 20, ENC_NA); tree = proto_item_add_subtree (ti, ett_packet); @@ -874,7 +876,18 @@ dissect_rpcap_packet (tvbuff_t *tvb, packet_info *pinfo, proto_tree *top_tree, new_tvb = tvb_new_subset (tvb, offset, caplen, len); if (decode_content && linktype != WTAP_ENCAP_UNKNOWN) { - dissector_try_uint(wtap_encap_dissector_table, linktype, new_tvb, pinfo, top_tree); + switch (linktype) { + + case WTAP_ENCAP_ETHERNET: + eth.fcs_len = -1; /* Unknown whether we have an FCS */ + phdr = &eth; + break; + + default: + phdr = NULL; + break; + } + dissector_try_uint_new(wtap_encap_dissector_table, linktype, new_tvb, pinfo, top_tree, TRUE, phdr); if (!info_added) { /* Only indicate when not added before */
1