Skip to content

Commit e33a4fc

Browse files
author
Etienne Stalmans
committed
fix utils, read unicode string index out of bounds
1 parent 80a7509 commit e33a4fc

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

forms/rulerforms.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ func CreateFormAttachmentPointer(folderid, messageid []byte) error {
3232

3333
//CreateFormAttachmentTemplate creates the template attachment holding the actual command to execute
3434
func CreateFormAttachmentTemplate(folderid, messageid []byte, pstr string) error {
35+
return CreateFormAttachmentWithTemplate(folderid, messageid, pstr, "templates/formtemplate.bin")
36+
}
37+
38+
//CreateFormAttachmentForDeleteTemplate creates the template attachment holding the actual command to execute
39+
func CreateFormAttachmentForDeleteTemplate(folderid, messageid []byte, pstr string) error {
40+
return CreateFormAttachmentWithTemplate(folderid, messageid, pstr, "templates/formdeletetemplate.bin")
41+
}
3542

43+
//CreateFormAttachmentWithTemplate creates a form with a specific template
44+
func CreateFormAttachmentWithTemplate(folderid, messageid []byte, pstr, templatepath string) error {
3645
utils.Info.Println("Create Form Template Attachment")
3746

3847
attachmentPropertyTags := make([]mapi.TaggedPropertyValue, 4)
@@ -43,8 +52,7 @@ func CreateFormAttachmentTemplate(folderid, messageid []byte, pstr string) error
4352
res, _ := mapi.CreateMessageAttachment(folderid, messageid, attachmentPropertyTags)
4453

4554
//read the template file for our payload
46-
path := "templates/formtemplate.bin"
47-
datafull, err := utils.ReadFile(path)
55+
datafull, err := utils.ReadFile(templatepath)
4856
if err != nil {
4957
utils.Error.Println(err)
5058
if os.IsNotExist(err) {

templates/formdeletetemplate.bin

42 KB
Binary file not shown.

utils/utils.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ func ReadByte(pos int, buff []byte) (byte, int) {
214214
func ReadUnicodeString(pos int, buff []byte) ([]byte, int) {
215215
//stupid hack as using bufio and ReadString(byte) would terminate too early
216216
//would terminate on 0x00 instead of 0x0000
217-
index := bytes.Index(buff[pos:], []byte{0x00, 0x00, 0x00})
217+
index := bytes.Index(buff[pos:], []byte{0x00, 0x00, 0x00}) + 1
218218
str := buff[pos : pos+index]
219-
return []byte(str), pos + index + 2
219+
return []byte(str), pos + index + 1
220220
}
221221

222222
//ReadASCIIString returns a string as ascii

0 commit comments

Comments
 (0)