mirror of
https://github.com/clearml/dropbear
synced 2025-01-31 02:46:58 +00:00
Add m_snprintf() that won't return negative
This commit is contained in:
parent
552385280a
commit
ac2433cb8d
13
dbutil.c
13
dbutil.c
@ -771,3 +771,16 @@ int fd_read_pending(int fd) {
|
||||
return FD_ISSET(fd, &fds);
|
||||
}
|
||||
}
|
||||
|
||||
int m_snprintf(char *str, size_t size, const char *format, ...) {
|
||||
va_list param;
|
||||
int ret;
|
||||
|
||||
va_start(param, format);
|
||||
ret = vsnprintf(str, size, format, param);
|
||||
va_end(param);
|
||||
if (ret < 0) {
|
||||
dropbear_exit("snprintf failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
2
dbutil.h
2
dbutil.h
@ -73,6 +73,8 @@ void m_close(int fd);
|
||||
void setnonblocking(int fd);
|
||||
void disallow_core(void);
|
||||
int m_str_to_uint(const char* str, unsigned int *val);
|
||||
/* The same as snprintf() but exits rather than returning negative */
|
||||
int m_snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
/* Used to force mp_ints to be initialised */
|
||||
#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
|
||||
|
Loading…
Reference in New Issue
Block a user