Skip to content

Commit

Permalink
Fix strncpy warning with GCC on latest Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
vaintroub committed Jul 28, 2023
1 parent 03743f9 commit 5a44d82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sb_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void log_errno(log_msg_priority_t priority, const char *fmt, ...)
tmp = errbuf;
#endif /* STRERROR_R_CHAR_P */
#else /* !HAVE_STRERROR_P */
strncpy(errbuf, strerror(old_errno), sizeof(errbuf));
strncpy(errbuf, strerror(old_errno), sizeof(errbuf)-1);
tmp = errbuf;
#endif /* HAVE_STRERROR_P */

Expand Down Expand Up @@ -447,7 +447,7 @@ int text_handler_process(log_msg_t *msg)
printf("(last message repeated %u times)\n", text_cnt);

text_cnt = 0;
strncpy(text_buf, text_msg->text, TEXT_BUFFER_SIZE);
strncpy(text_buf, text_msg->text, TEXT_BUFFER_SIZE - 1);
}
pthread_mutex_unlock(&text_mutex);
}
Expand Down

0 comments on commit 5a44d82

Please sign in to comment.