aboutsummaryrefslogtreecommitdiffstats
path: root/frame.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 05:46:34 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 05:46:34 +0000
commit3a0010d25f9522a470dbd3ad37889a62d325e137 (patch)
tree064cead28cf1140ccb48f249201824be7a0a0f00 /frame.c
parent4375bcc8e538417cb0d7cb18334b7385b5867219 (diff)
minor cleanups (bug #4158)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5674 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rwxr-xr-xframe.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/frame.c b/frame.c
index b75c38932..e52881fe2 100755
--- a/frame.c
+++ b/frame.c
@@ -259,6 +259,11 @@ void ast_frfree(struct ast_frame *fr)
}
}
+/*
+ * 'isolates' a frame by duplicating non-malloc'ed components
+ * (header, src, data).
+ * On return all components are malloc'ed
+ */
struct ast_frame *ast_frisolate(struct ast_frame *fr)
{
struct ast_frame *out;
@@ -271,11 +276,11 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
}
out->frametype = fr->frametype;
out->subclass = fr->subclass;
- out->datalen = 0;
+ out->datalen = fr->datalen;
out->samples = fr->samples;
- out->offset = 0;
+ out->offset = fr->offset;
out->src = NULL;
- out->data = NULL;
+ out->data = fr->data;
} else {
out = fr;
}
@@ -308,6 +313,10 @@ struct ast_frame *ast_frdup(struct ast_frame *f)
/* Start with standard stuff */
len = sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + f->datalen;
/* If we have a source, add space for it */
+ /*
+ * XXX Watch out here - if we receive a src which is not terminated
+ * properly, we can be easily attacked. Should limit the size we deal with.
+ */
if (f->src)
srclen = strlen(f->src);
if (srclen > 0)
@@ -338,6 +347,13 @@ struct ast_frame *ast_frdup(struct ast_frame *f)
return out;
}
+#if 0
+/*
+ * XXX
+ * This function is badly broken - it does not handle correctly
+ * partial reads on either header or body.
+ * However is it never used anywhere so we leave it commented out
+ */
struct ast_frame *ast_fr_fdread(int fd)
{
char buf[65536];
@@ -386,6 +402,11 @@ struct ast_frame *ast_fr_fdread(int fd)
/* Some convenient routines for sending frames to/from stream or datagram
sockets, pipes, etc (maybe even files) */
+/*
+ * XXX this function is also partly broken because it does not handle
+ * partial writes. We comment it out too, and also the unique
+ * client it has, ast_fr_fdhangup()
+ */
int ast_fr_fdwrite(int fd, struct ast_frame *frame)
{
/* Write the frame exactly */
@@ -409,6 +430,7 @@ int ast_fr_fdhangup(int fd)
return ast_fr_fdwrite(fd, &hangup);
}
+#endif /* unused functions */
void ast_swapcopy_samples(void *dst, const void *src, int samples)
{
int i;