service: fixed buffer too low error (#1745)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
parent
9f29fc8a9c
commit
c6ee794598
|
@ -440,6 +440,8 @@ func (c *Collector) getServiceConfig(service *mgr.Service) (mgr.Config, error) {
|
|||
buf, ok := c.serviceConfigPoolBytes.Get().(*[]byte)
|
||||
if !ok || len(*buf) == 0 {
|
||||
*buf = make([]byte, bytesNeeded)
|
||||
} else {
|
||||
bytesNeeded = uint32(cap(*buf))
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -450,12 +452,12 @@ func (c *Collector) getServiceConfig(service *mgr.Service) (mgr.Config, error) {
|
|||
break
|
||||
}
|
||||
|
||||
if !errors.Is(err, windows.ERROR_INSUFFICIENT_BUFFER) {
|
||||
if !errors.Is(err, windows.ERROR_INSUFFICIENT_BUFFER) && !errors.Is(err, windows.ERROR_MORE_DATA) {
|
||||
return mgr.Config{}, err
|
||||
}
|
||||
|
||||
if bytesNeeded <= uint32(len(*buf)) {
|
||||
return mgr.Config{}, err
|
||||
return mgr.Config{}, fmt.Errorf("win32 reports buffer too small (%d), but buffer is large enough (%d): %w", uint32(cap(*buf)), bytesNeeded, err)
|
||||
}
|
||||
|
||||
*buf = make([]byte, bytesNeeded)
|
||||
|
|
Loading…
Reference in New Issue