ptr += templen;
templen = snprintf(ptr, len, "%06u ", (int)tv.tv_usec);
+ if (templen == -1 || templen >= len)
+ return;
+
len -= templen;
ptr += templen;
/* PID */
pid = getpid();
templen = snprintf(ptr, len, "[%d]", pid);
+ if (templen == -1 || templen >= len)
+ return;
len -= templen;
ptr += templen;
templen = snprintf(ptr, len, " {%s:%d}", basename + 1, log_src_linenumber);
else
templen = snprintf(ptr, len, " {%s:%d}", log_src_filename, log_src_linenumber);
- if (templen >= len)
+ if (templen == -1 || templen >= len)
return;
len -= templen;
ptr += templen;
templen = snprintf(ptr, len, " (D%d:", loglevel - 1);
else
templen = snprintf(ptr, len, " (%c:", arr_loglevel_chars[loglevel]);
+ if (templen == -1 || templen >= len)
+ return;
len -= templen;
ptr += templen;
/* Errortype */
if (logtype<num_logtype_strings) {
templen = snprintf(ptr, len, "%s", arr_logtype_strings[logtype]);
+ if (templen == -1 || templen >= len)
+ return;
len -= templen;
ptr += templen;
}
va_end(args);
/* Append \n */
- if (len >= MAXLOGSIZE)
+ if (len ==-1 || len >= MAXLOGSIZE)
/* vsnprintf hit the buffer size*/
temp_buffer[MAXLOGSIZE-2] = '\n';
else {
va_start(args, message);
vsnprintf(log_buffer, sizeof(log_buffer), message, args);
va_end(args);
-
+ log_buffer[MAXLOGSIZE -1] = 0;
syslog(get_syslog_equivalent(loglevel), "%s", log_buffer);
inlog = 0;
{
static char buf[ MAXPATHLEN + 1];
struct stat st;
+ int len;
if ((stat(path, &st)) != 0)
return -1;
if (S_ISDIR(st.st_mode)) {
- if ((snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path)) < 0)
+ len = snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path);
+ if (len < 0 || len >= MAXPATHLEN)
return -1;
/* set acl on .AppleDouble dir first */
if ((acl(buf, cmd, count, aces)) != 0)
{
int ret;
static char buf[ MAXPATHLEN + 1];
+ int len;
if (dir) {
- if ((snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path)) < 0)
+ len = snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path);
+ if (len < 0 || len >= MAXPATHLEN)
return AFPERR_MISC;
/* remove ACL from .AppleDouble/.Parent first */
if ((ret = remove_acl(vol->vfs->ad_path(path, ADFLAGS_DIR))) != AFP_OK)