Differences From Artifact [ceca032601f4821d]:
- File
jim-aio.c
-
2010-11-23 23:40:45
- part of checkin
[3369aea7dd]
on branch trunk
- Remove the bio extension and add 'copyto' to aio.
The bio extension is a hangover from TinyTcl. Since Jim supports binary strings, there isn't much need for it except for 'bio copy'. So move this to aio as 'copyto' and implement 'file copy' in terms of it.
Signed-off-by: Steve Bennett <steveb@workware.net.au> (user: steveb@workware.net.au
-
2010-11-23 23:40:45
- part of checkin
[3369aea7dd]
on branch trunk
- Remove the bio extension and add 'copyto' to aio.
To Artifact [2f50ac333b8897e3]:
- File
jim-aio.c
-
2011-01-24 06:13:06
- part of checkin
[321457ea9d]
on branch trunk
- Use snprintf() to avoid buffer overflow
The only real potential overflow is parsing a bogus unix domain socket path.
Signed-off-by: Steve Bennett <steveb@workware.net.au> (user: steveb@workware.net.au
-
2011-01-24 06:13:06
- part of checkin
[321457ea9d]
on branch trunk
- Use snprintf() to avoid buffer overflow
248 248 return ret;
249 249 }
250 250
251 251 #ifdef HAVE_SYS_UN_H
252 252 static int JimParseDomainAddress(Jim_Interp *interp, const char *path, struct sockaddr_un *sa)
253 253 {
254 254 sa->sun_family = PF_UNIX;
255 - strcpy(sa->sun_path, path);
255 + snprintf(sa->sun_path, sizeof(sa->sun_path), "%s", path);
256 256
257 257 return JIM_OK;
258 258 }
259 259 #endif
260 260 #endif
261 261
262 262 static void JimAioSetError(Jim_Interp *interp, Jim_Obj *name)
................................................................................
604 604 #ifdef O_NDELAY
605 605 af->flags = fcntl(af->fd, F_GETFL);
606 606 #endif
607 607 af->rEvent = NULL;
608 608 af->wEvent = NULL;
609 609 af->eEvent = NULL;
610 610 af->addr_family = serv_af->addr_family;
611 - sprintf(buf, "aio.sockstream%ld", Jim_GetId(interp));
611 + snprintf(buf, sizeof(buf), "aio.sockstream%ld", Jim_GetId(interp));
612 612 Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc);
613 613 Jim_SetResultString(interp, buf, -1);
614 614 return JIM_OK;
615 615 }
616 616
617 617 #endif
618 618
................................................................................
945 945 #endif
946 946 fp = fopen(filename, mode);
947 947 if (fp == NULL) {
948 948 JimAioSetError(interp, argv[1]);
949 949 return JIM_ERR;
950 950 }
951 951 /* Get the next file id */
952 - sprintf(buf, "aio.handle%ld", Jim_GetId(interp));
952 + snprintf(buf, sizeof(buf), "aio.handle%ld", Jim_GetId(interp));
953 953 cmdname = buf;
954 954 }
955 955
956 956 /* Create the file command */
957 957 af = Jim_Alloc(sizeof(*af));
958 958 af->fp = fp;
959 959 af->fd = fileno(fp);