if(NULL==output) { return -1; }
i = size_int(len);
- i += 2; // account for ':' and '\0'
- i += len;
+ i++; // account for ':'
+ if(i+len>output_size) { return -1; }
- if(i>output_size) { return -1; }
+ // snprintf requires space for '\0' otherwise will truncate
+ if(snprintf((char*)output,i+1,"%lu:",len)!=i) { return -1; }
- return snprintf((char*)output,i,"%lu:%s",len,(const char*)str);
+ memcpy(&(output[i]),str,len);
+
+ return i+len;
}
$(top_srcdir)/src/fs/concat.c \
$(top_srcdir)/src/hash.c \
$(top_srcdir)/src/hashmap.c \
- $(top_srcdir)/src/torrent.c \
+ $(top_srcdir)/src/torrent/add.c \
+ $(top_srcdir)/src/torrent/init.c \
+ $(top_srcdir)/src/torrent/free.c \
$(top_srcdir)/src/tree.c
tree_tests_SOURCES = \