Skip to content

Commit

Permalink
Fix strlcpy / strlcat detection in configure.ac, fix small memory lea…
Browse files Browse the repository at this point in the history
…k in pgdbf.c

Verified to build on Mac OS X 10.7 and Arch Linux.
  • Loading branch information
philwo committed Mar 25, 2012
1 parent 2279f79 commit 5773830
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config.h.in
Expand Up @@ -43,6 +43,12 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H

/* Define to 1 if you have the `strlcat' function. */
#undef HAVE_STRLCAT

/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY

/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -30,7 +30,7 @@ AC_C_BIGENDIAN
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MMAP
AC_CHECK_FUNCS([munmap strchr])
AC_CHECK_FUNCS([munmap strchr strlcpy strlcat])

AC_ARG_ENABLE([installdocs],
[ --enable-installdocs install documentation],
Expand Down
10 changes: 10 additions & 0 deletions src/pgdbf.c
Expand Up @@ -29,6 +29,14 @@
#include <sys/stat.h>
#include <sys/types.h>

#if !defined (HAVE_STRLCPY)
#include "strlcpy.h"
#endif

#if !defined (HAVE_STRLCAT)
#include "strlcat.h"
#endif

#include "pgdbf.h"

int main(int argc, char **argv) {
Expand Down Expand Up @@ -763,6 +771,8 @@ int main(int argc, char **argv) {
close(memofd);
}

free(optvalidargs);

#if defined(HAVE_ICONV_H)
if(conv_desc != NULL) {
if(iconv_close(conv_desc) != 0) {
Expand Down
1 change: 1 addition & 0 deletions src/pgdbf.h
Expand Up @@ -305,6 +305,7 @@ static void safeprintbuf(const char *buf, const size_t inputsize) {
}
}
*t = '\0';

printf("%s", targetbuf);

#if defined(HAVE_ICONV_H)
Expand Down

0 comments on commit 5773830

Please sign in to comment.