offset = get_off_t(&ibuf, is64);
reqcount = get_off_t(&ibuf, is64);
+ /* zero request count */
+ err = AFP_OK;
+ if (!reqcount) {
+ goto afp_read_err;
+ }
+
/* reqcount isn't always truthful. we need to deal with that. */
size = ad_size(ofork->of_ad, eid);
"afp_read(off: %" PRIu64 ", len: %" PRIu64 ", fork: %s, size: %" PRIu64 ")",
offset, reqcount, (ofork->of_flags & AFPFORK_DATA) ? "d" : "r", size);
+ if (offset > size) {
+ err = AFPERR_EOF;
+
+ }
+
/* subtract off the offset */
if (reqcount + offset > size) {
reqcount = size - offset;
err = AFPERR_EOF;
+ goto afp_read_err;
}
savereqcount = reqcount;
goto afp_read_err;
}
- /* zero request count */
- err = AFP_OK;
- if (!reqcount) {
- goto afp_read_err;
- }
-
LOG(log_debug, logtype_afpd, "afp_read(name: \"%s\", offset: %jd, reqcount: %jd)",
of_name(ofork), (intmax_t)offset, (intmax_t)reqcount);