mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-07 11:30:18 +00:00
Return Invalid bundle status if rhizome manifest not found during import
This commit is contained in:
parent
6c4e7de574
commit
cc0d6fcdb9
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
package org.servalproject.servaldna;
|
package org.servalproject.servaldna;
|
||||||
|
|
||||||
|
import org.servalproject.servaldna.rhizome.RhizomeBundleStatus;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -347,6 +349,10 @@ public class ServalDCommand
|
|||||||
public long rowId;
|
public long rowId;
|
||||||
public long insertTime;
|
public long insertTime;
|
||||||
|
|
||||||
|
public RhizomeBundleStatus getBundleStatus() throws RhizomeBundleStatus.InvalidException {
|
||||||
|
return RhizomeBundleStatus.fromCode(result);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putString(String value) {
|
public void putString(String value) {
|
||||||
try {
|
try {
|
||||||
|
@ -34,7 +34,9 @@ public enum RhizomeBundleStatus {
|
|||||||
FAKE(5), // manifest signature not valid
|
FAKE(5), // manifest signature not valid
|
||||||
INCONSISTENT(6), // manifest filesize/filehash does not match supplied payload
|
INCONSISTENT(6), // manifest filesize/filehash does not match supplied payload
|
||||||
NO_ROOM(7), // doesn't fit; store may contain more important bundles
|
NO_ROOM(7), // doesn't fit; store may contain more important bundles
|
||||||
READONLY(8) // cannot modify manifest; secret unknown
|
READONLY(8), // cannot modify manifest; secret unknown
|
||||||
|
BUSY(9), // the backend was busy, you can try again
|
||||||
|
TOO_BIG(10) // manifest is too large
|
||||||
;
|
;
|
||||||
|
|
||||||
final public int code;
|
final public int code;
|
||||||
|
12
rhizome.c
12
rhizome.c
@ -429,7 +429,8 @@ enum rhizome_bundle_status rhizome_bundle_import_files(rhizome_manifest *m, rhiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EOCD){
|
if (!EOCD){
|
||||||
ret=WHY("Expected zip EOCD marker 0x504b0506 near end of file");
|
WHY("Expected zip EOCD marker 0x504b0506 near end of file");
|
||||||
|
ret = RHIZOME_BUNDLE_STATUS_INVALID;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +439,8 @@ enum rhizome_bundle_status rhizome_bundle_import_files(rhizome_manifest *m, rhiz
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
if (buff[read_len-2]!=0x41 || buff[read_len-1]!=0x10){
|
if (buff[read_len-2]!=0x41 || buff[read_len-1]!=0x10){
|
||||||
ret=WHYF("Expected 0x4110 marker at end of file");
|
WHYF("Expected 0x4110 marker at end of file");
|
||||||
|
ret = RHIZOME_BUNDLE_STATUS_INVALID;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
m->manifest_all_bytes = read_uint16(&buff[read_len-4]);
|
m->manifest_all_bytes = read_uint16(&buff[read_len-4]);
|
||||||
@ -450,11 +452,13 @@ enum rhizome_bundle_status rhizome_bundle_import_files(rhizome_manifest *m, rhiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m->manifest_all_bytes < 1 || m->manifest_all_bytes > MAX_MANIFEST_BYTES){
|
if (m->manifest_all_bytes < 1 || m->manifest_all_bytes > MAX_MANIFEST_BYTES){
|
||||||
ret=WHYF("Invalid manifest length %zu", m->manifest_all_bytes);
|
WHYF("Invalid manifest length %zu", m->manifest_all_bytes);
|
||||||
|
ret = RHIZOME_BUNDLE_STATUS_INVALID;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (manifest_ptr < buff || manifest_ptr + m->manifest_all_bytes > buff + read_len){
|
if (manifest_ptr < buff || manifest_ptr + m->manifest_all_bytes > buff + read_len){
|
||||||
ret=WHY("Invalid manifest offset");
|
WHY("Invalid manifest offset");
|
||||||
|
ret = RHIZOME_BUNDLE_STATUS_INVALID;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
bcopy(manifest_ptr, m->manifestdata, m->manifest_all_bytes);
|
bcopy(manifest_ptr, m->manifestdata, m->manifest_all_bytes);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user