$Log$
+Revision 323.39 2002/06/15 20:34:39 ajc
+* Use safestrncpy() instead of strncpy() where appropriate
+* Fixed a memory allocation bug in the vCard parser
+
Revision 323.38 2002/05/23 03:40:05 ajc
* Brought over a utility function I'll need later
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
-
sprintf(tbuf, "%d.%d.%d.%d", a1, a2, a3, a4);
return;
}
- strncpy(tbuf, ch->h_name, 64);
+ safestrncpy(tbuf, ch->h_name, 64);
tbuf[63] = 0;
}
end = pos;
}
- strncpy(urlbuf, &buf[start], end - start);
+ safestrncpy(urlbuf, &buf[start], end - start);
urlbuf[end - start] = 0;
-
- strncpy(outbuf, buf, start);
+ safestrncpy(outbuf, buf, start);
sprintf(&outbuf[start], "%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
strcat(outbuf, &buf[end]);
if ((size = vsprintf(p, fmt, argp)) >= max)
size = -1;
- strncpy(buf, p, max);
+ safestrncpy(buf, p, max);
buf[max - 1] = 0;
free(p);
return size;
strcpy(inbuf, "");
}
else {
- strncpy(outbuf, inbuf, pos);
+ safestrncpy(outbuf, inbuf, pos);
outbuf[pos] = 0;
wprintf("%s", outbuf);
strcpy(inbuf, &inbuf[pos]);
for (i=strlen(inbuf); i>=0; --i) {
if (inbuf[i]=='>') pos = i;
}
- strncpy(key, &inbuf[2], pos-2);
+ safestrncpy(key, &inbuf[2], pos-2);
key[pos-2] = 0;
print_value_of(key);
strcpy(inbuf, &inbuf[pos+1]);
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
+ safestrncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
colonpos = pattern2(ptr, ":");
nlpos = pattern2(ptr, "\n");
- if (nlpos > colonpos > 0) {
+ if ((nlpos > colonpos) && (colonpos > 0)) {
namebuf = malloc(colonpos + 1);
valuebuf = malloc(nlpos - colonpos + 1);
- strncpy(namebuf, ptr, colonpos);
+ safestrncpy(namebuf, ptr, colonpos);
namebuf[colonpos] = 0;
- strncpy(valuebuf, &ptr[colonpos+1], nlpos-colonpos-1);
+ safestrncpy(valuebuf, &ptr[colonpos+1], nlpos-colonpos-1);
valuebuf[nlpos-colonpos-1] = 0;
if ( (!strcasecmp(namebuf, "end"))
while (strlen(up) > 0) {
/* locate the = sign */
- strncpy(buf, up, 255);
+ safestrncpy(buf, up, sizeof buf);
b = (-1);
for (a = 255; a >= 0; --a)
if (buf[a] == '=')
void set_preference(char *key, char *value);
void knrooms(void);
int is_msg_in_mset(char *mset, long msgnum);
+char *safestrncpy(char *dest, const char *src, size_t n);