u9fs/safecpy.c

15 lines
252 B
C
Raw Normal View History

2011-05-12 23:09:50 +02:00
#include <stdlib.h>
#include <string.h>
2011-05-12 23:06:54 +02:00
#include <stdio.h>
void
safecpy(char *to, char *from, int tolen)
{
int fromlen;
memset(to, 0, tolen);
fromlen = from ? strlen(from) : 0;
if (fromlen > tolen)
fromlen = tolen;
memcpy(to, from, fromlen);
}