mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 12:20:12 +00:00
Postgres driver doesn't like a NULL pointer when retrieving the length (Bug 8513)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@51158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -932,7 +932,7 @@ static int retrieve_file(char *dir, int msgnum)
|
|||||||
}
|
}
|
||||||
if (!strcasecmp(coltitle, "recording")) {
|
if (!strcasecmp(coltitle, "recording")) {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
res = SQLGetData(stmt, x + 1, SQL_BINARY, NULL, 0, &colsize);
|
res = SQLGetData(stmt, x + 1, SQL_BINARY, rowdata, 0, &colsize);
|
||||||
fdlen = colsize;
|
fdlen = colsize;
|
||||||
if (fd > -1) {
|
if (fd > -1) {
|
||||||
char tmp[1]="";
|
char tmp[1]="";
|
||||||
@@ -944,14 +944,13 @@ static int retrieve_file(char *dir, int msgnum)
|
|||||||
}
|
}
|
||||||
/* Read out in small chunks */
|
/* Read out in small chunks */
|
||||||
for (offset = 0; offset < colsize; offset += CHUNKSIZE) {
|
for (offset = 0; offset < colsize; offset += CHUNKSIZE) {
|
||||||
/* +1 because SQLGetData likes null-terminating binary data */
|
if ((fdm = mmap(NULL, CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == (void *)-1) {
|
||||||
if ((fdm = mmap(NULL, CHUNKSIZE + 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == -1) {
|
|
||||||
ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno);
|
ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno);
|
||||||
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
||||||
goto yuck;
|
goto yuck;
|
||||||
} else {
|
} else {
|
||||||
res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, CHUNKSIZE + 1, NULL);
|
res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, CHUNKSIZE, NULL);
|
||||||
munmap(fdm, 0);
|
munmap(fdm, CHUNKSIZE);
|
||||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||||
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
|
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
|
||||||
unlink(full_fn);
|
unlink(full_fn);
|
||||||
|
Reference in New Issue
Block a user