mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Merge pull request #2843 from c-edw/feature/2842_TruncateMessage
swaynag: Truncate message to 2048 chars.
This commit is contained in:
commit
434cbaabf0
1 changed files with 9 additions and 6 deletions
|
@ -10,6 +10,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
|
static const char *overflow = "[buffer overflow]";
|
||||||
|
static const int max_chars = 16384;
|
||||||
|
|
||||||
size_t escape_markup_text(const char *src, char *dest) {
|
size_t escape_markup_text(const char *src, char *dest) {
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
if (dest) {
|
if (dest) {
|
||||||
|
@ -84,12 +87,12 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
|
||||||
|
|
||||||
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
|
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
|
||||||
int *baseline, double scale, bool markup, const char *fmt, ...) {
|
int *baseline, double scale, bool markup, const char *fmt, ...) {
|
||||||
static char buf[2048];
|
char buf[max_chars];
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
if (vsnprintf(buf, 2048, fmt, args) >= 2048) {
|
if (vsnprintf(buf, sizeof(buf), fmt, args) >= max_chars) {
|
||||||
strcpy(buf, "[buffer overflow]");
|
strcpy(&buf[sizeof(buf) - sizeof(overflow)], overflow);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
@ -104,12 +107,12 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
|
||||||
|
|
||||||
void pango_printf(cairo_t *cairo, const char *font,
|
void pango_printf(cairo_t *cairo, const char *font,
|
||||||
double scale, bool markup, const char *fmt, ...) {
|
double scale, bool markup, const char *fmt, ...) {
|
||||||
static char buf[2048];
|
char buf[max_chars];
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
if (vsnprintf(buf, 2048, fmt, args) >= 2048) {
|
if (vsnprintf(buf, sizeof(buf), fmt, args) >= max_chars) {
|
||||||
strcpy(buf, "[buffer overflow]");
|
strcpy(&buf[sizeof(buf) - sizeof(overflow)], overflow);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue