github-vet / github-vet/rangeloop-pointer-findings
kaiakz/rsync-os: rsync/sender.go; 97 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kaiakz/rsync-os](https://www.github.com/kaiakz/rsync-os) at [rsync/sender.go](https://github.com/kaiakz/rsync-os/blob/fc4546fa9c1b00dbf1eef665f6f348ce1f8b93e4/rsync/sender.go#L25-L121)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to f is reassigned at line 120
[Click here to see the code in its original context.](https://github.com/kaiakz/rsync-os/blob/fc4546fa9c1b00dbf1eef665f6f348ce1f8b93e4/rsync/sender.go#L25-L121)
Click here to show the 97 line(s) of Go which triggered the analyzer.
```go
for _, f := range list{
var flags byte = 0
if bytes.Equal(f.Path, []byte(".")) {
if f.Mode.IsDIR() {
flags |= FLIST_TOP_LEVEL
}
} else {
if f.Mode.IsDIR() { // TODO: recursive
// flags |= Flags.NO_CONTENT_DIR | Flags.XFLAGS;
}
}
lPathCount := 0
if last != nil {
lPathCount = longestMatch(last.Path, f.Path)
if lPathCount > 255 { // Limit to 255 chars
lPathCount = 255
}
if lPathCount > 0 {
flags |= FLIST_NAME_SAME
}
if last.Mode == f.Mode {
flags |= FLIST_MODE_SAME
}
if last.Mtime == f.Mtime {
flags |= FLIST_TIME_SAME
}
//
//
//
}
rPathCount := int32(len(f.Path) - lPathCount)
if rPathCount > 255 {
flags |= FLIST_NAME_LONG
}
/* we must make sure we don't send a zero flags byte or the other
end will terminate the flist transfer */
if flags == 0 && !f.Mode.IsDIR() {
flags |= 1<<0
}
if flags == 0 {
flags |= FLIST_NAME_LONG
}
/* Send flags */
if err != s.conn.WriteByte(flags) {
return err
}
/* Send len of path, and bytes of path */
if flags& FLIST_NAME_SAME != 0 {
if err = s.conn.WriteByte(flags); err != nil {
return err
}
}
if flags& FLIST_NAME_LONG != 0 {
if err = s.conn.WriteInt(rPathCount); err != nil {
return err
}
} else {
if err = s.conn.WriteByte(byte(rPathCount)); err != nil {
return err
}
}
if _, err = s.conn.Write(f.Path[lPathCount:]); err != nil {
return err
}
/* Send size of file */
if err = s.conn.WriteLong(f.Size); err != nil {
return err
}
/* Send Mtime, GID, UID, RDEV if needed */
if flags& FLIST_TIME_SAME == 0 {
if err = s.conn.WriteInt(f.Mtime); err != nil {
return err
}
}
if flags& FLIST_MODE_SAME == 0 {
if err = s.conn.WriteInt(int32(f.Mode)); err != nil {
return err
}
}
// TODO: UID GID RDEV
// TODO: Send symlink
// TODO: if always_checksum?
last = &f
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: fc4546fa9c1b00dbf1eef665f6f348ce1f8b93e4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.