commit - ff6f19b17c7e1d33ec438ee331f1aa3080903acd
commit + 91f48e256d92ce302b75d6cc208c09d4aaac5377
blob - 8b7e6b2853ae287fe51e08e0c1ac961350ab6458
blob + a8396245e632897fe7177081b9411928e1b6c680
--- kamid/client.c
+++ kamid/client.c
client_shutdown();
}
-static inline void
+static inline int
serialize_stat(const char *fname, struct stat *sb, struct evbuffer *evb)
{
struct qid qid;
ulen = strlen(muid);
tot = NPSTATSIZ(namlen, uidlen, gidlen, ulen);
- if (tot > UINT32_MAX) {
+ if (tot > UINT16_MAX) {
log_warnx("stat info for dir entry %s would overflow",
fname);
- return;
+ return -1;
}
np_write16(evb, tot); /* size[2] */
np_string(evb, uidlen, uid); /* uid[s] */
np_string(evb, gidlen, gid); /* gid[s] */
np_string(evb, ulen, muid); /* muid[s] */
+
+ return 0;
}
static void
return;
}
- serialize_stat(f->fname, &sb, evb);
- np_stat(hdr->tag, EVBUFFER_LENGTH(evb), EVBUFFER_DATA(evb));
+ if (serialize_stat(f->fname, &sb, evb) == -1)
+ np_error(hdr->tag, "stat would overflow");
+ else
+ np_stat(hdr->tag, EVBUFFER_LENGTH(evb), EVBUFFER_DATA(evb));
evbuffer_free(evb);
}