Skip to content

Commit

Permalink
Merge pull request #124 from kishikawakatsumi/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
kishikawakatsumi authored Sep 9, 2024
2 parents 988c2fa + 907d837 commit 3255ef4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/SMBClient/DCERPC/NetShareEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,19 @@ struct WStr {

init(referentID: UInt32, byteReader: ByteReader) {
self.referentID = referentID

maxCount = byteReader.read()
offset = byteReader.read()
actualCount = byteReader.read()

let valueCount = Int(actualCount) * 2
valueData = byteReader.read(count: valueCount)
if valueCount % 4 != 0 {
terminator = byteReader.read()
} else {
terminator = 0
}

let valueData = Data(valueData)[0..<valueData.count - 2]
value = String(data: valueData, encoding: .utf16LittleEndian) ?? valueData.hex
}
Expand All @@ -89,6 +92,7 @@ struct WStr {
var data = Data()
data += referentID
data += maxCount

if valueData.isEmpty {
data += offset
} else {
Expand Down Expand Up @@ -167,7 +171,7 @@ struct NetShareEnumResponse {
let commentRefferentID: UInt32 = byteReader.read()
return (nameRefferentID, type, commentRefferentID)
}
.map { nameRefferentID, type, commentRefferentID in
.map { (nameRefferentID, type, commentRefferentID) in
let name = WStr(referentID: nameRefferentID, byteReader: byteReader)
let comment = WStr(referentID: commentRefferentID, byteReader: byteReader)
return ShareInfo1(name: name, type: type, comment: comment)
Expand Down

0 comments on commit 3255ef4

Please sign in to comment.