Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/iolog/iolog_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ iolog_write(struct iolog_file *iol, const void *buf, size_t len,
#endif
{
ret = (ssize_t)fwrite(buf, 1, len, iol->fd.f);
if (ret <= 0) {
if (ret != (ssize_t)len) {
ret = -1;
if (errstr != NULL)
*errstr = strerror(errno);
Expand Down
2 changes: 1 addition & 1 deletion plugins/python/regress/iohelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fwriteall(const char *file_path, const char *string)
goto cleanup;

size_t size = strlen(string);
if (fwrite(string, 1, size, file) < size) {
if (fwrite(string, 1, size, file) != size) {
goto cleanup;
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/sudoers/sudo_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ sudo_printf_int(int msg_type, const char * restrict fmt, ...)
len = vasprintf(&buf, fmt, ap);
va_end(ap);
}
if (len != -1) {
if (fwrite(buf, 1, (size_t)len, ttyfp ? ttyfp : fp) == 0)
if (len >= 0) {
if (fwrite(buf, 1, (size_t)len, ttyfp ? ttyfp : fp) != (size_t)len)
len = -1;
if (buf != sbuf)
free(buf);
Expand Down
8 changes: 4 additions & 4 deletions src/conversation.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ sudo_conversation(int num_msgs, const struct sudo_conv_message msgs[],
close(ttyfd);
}
if (!written) {
if (len != 0 && fwrite(msg->msg, 1, len, fp) == 0)
if (len != 0 && fwrite(msg->msg, 1, len, fp) != len)
goto err;
if (crnl != NULL && fwrite(crnl, 1, 2, fp) == 0)
if (crnl != NULL && fwrite(crnl, 1, 2, fp) != 2)
goto err;
}
}
Expand Down Expand Up @@ -218,8 +218,8 @@ sudo_conversation_printf(int msg_type, const char * restrict fmt, ...)
len = vasprintf(&buf, fmt, ap);
va_end(ap);
}
if (len != -1) {
if (fwrite(buf, 1, (size_t)len, ttyfp ? ttyfp : fp) == 0)
if (len >= 0) {
if (fwrite(buf, 1, (size_t)len, ttyfp ? ttyfp : fp) != (size_t)len)
len = -1;
if (buf != sbuf)
free(buf);
Expand Down