summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acinclude.m423
-rw-r--r--configure.ac1
-rw-r--r--scripts/repo-add.sh.in1
-rw-r--r--src/pacman/util.c38
-rw-r--r--src/pacman/util.h1
5 files changed, 53 insertions, 11 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 0f3a4426..740d9ecc 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -38,6 +38,29 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
fi
])
+dnl GCC_FORTIFY_SOURCE_CC
+dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates
+dnl CFLAGS
+AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_MSG_CHECKING(for FORTIFY_SOURCE support)
+ AC_TRY_COMPILE([#include <features.h>], [
+ int main() {
+ #if !(__GNUC_PREREQ (4, 1) )
+ #error No FORTIFY_SOURCE support
+ #endif
+ return 0;
+ }
+ ], [
+ AC_MSG_RESULT(yes)
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+ fi
+])
+
dnl GCC_VISIBILITY_CC
dnl checks -fvisibility=internal with the C compiler, if it exists then
dnl defines ENABLE_VISIBILITY_CC in both configure script and Makefiles
diff --git a/configure.ac b/configure.ac
index db88b447..2a6ab08c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -316,6 +316,7 @@ if test "x$debug" = "xyes" ; then
# Check for -fstack-protector availability
GCC_STACK_PROTECT_LIB
GCC_STACK_PROTECT_CC
+ GCC_FORTIFY_SOURCE_CC
CFLAGS="$CFLAGS -g -Wall -Werror"
else
AC_MSG_RESULT(no)
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 283ad07a..8ef940d0 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -37,6 +37,7 @@ startdir="$PWD"
umask 0022
msg() {
+ (( QUIET )) && return
local mesg=$1; shift
printf "==> ${mesg}\n" "$@" >&1
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index b0824cfb..5b4b2e80 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -531,10 +531,10 @@ void display_targets(const alpm_list_t *pkgs, int install)
double mbsize = 0.0;
mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
- asprintf(&str, "%s-%s [%.2f MB]", alpm_pkg_get_name(pkg),
+ pm_asprintf(&str, "%s-%s [%.2f MB]", alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg), mbsize);
} else {
- asprintf(&str, "%s-%s", alpm_pkg_get_name(pkg),
+ pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg));
}
targets = alpm_list_add(targets, str);
@@ -545,7 +545,7 @@ void display_targets(const alpm_list_t *pkgs, int install)
mbisize = isize / (1024.0 * 1024.0);
if(install) {
- asprintf(&str, _("Targets (%d):"), alpm_list_count(targets));
+ pm_asprintf(&str, _("Targets (%d):"), alpm_list_count(targets));
list_display(str, targets);
free(str);
printf("\n");
@@ -555,7 +555,7 @@ void display_targets(const alpm_list_t *pkgs, int install)
printf(_("Total Installed Size: %.2f MB\n"), mbisize);
}
} else {
- asprintf(&str, _("Remove (%d):"), alpm_list_count(targets));
+ pm_asprintf(&str, _("Remove (%d):"), alpm_list_count(targets));
list_display(str, targets);
free(str);
printf("\n");
@@ -589,14 +589,14 @@ static char *pkg_get_location(pmpkg_t *pkg)
dburl = alpm_db_get_url(db);
if(dburl) {
char *pkgurl = NULL;
- asprintf(&pkgurl, "%s/%s", dburl, alpm_pkg_get_filename(pkg));
+ pm_asprintf(&pkgurl, "%s/%s", dburl, alpm_pkg_get_filename(pkg));
return(pkgurl);
}
case PM_OP_UPGRADE:
return(strdup(alpm_pkg_get_filename(pkg)));
default:
string = NULL;
- asprintf(&string, "%s-%s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ pm_asprintf(&string, "%s-%s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
return(string);
}
}
@@ -647,7 +647,7 @@ void print_packages(const alpm_list_t *packages)
char *size;
double mbsize = 0.0;
mbsize = pkg_get_size(pkg) / (1024.0 * 1024.0);
- asprintf(&size, "%.2f", mbsize);
+ pm_asprintf(&size, "%.2f", mbsize);
string = strreplace(temp, "%s", size);
free(size);
free(temp);
@@ -777,6 +777,22 @@ int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...)
return(ret);
}
+int pm_asprintf(char **string, const char *format, ...)
+{
+ int ret = 0;
+ va_list args;
+
+ /* print the message using va_arg list */
+ va_start(args, format);
+ if(vasprintf(string, format, args) == -1) {
+ pm_fprintf(stderr, PM_LOG_ERROR, _("failed to allocate string\n"));
+ ret = -1;
+ }
+ va_end(args);
+
+ return(ret);
+}
+
int pm_vasprintf(char **string, pmloglevel_t level, const char *format, va_list args)
{
int ret = 0;
@@ -793,16 +809,16 @@ int pm_vasprintf(char **string, pmloglevel_t level, const char *format, va_list
/* print a prefix to the message */
switch(level) {
case PM_LOG_DEBUG:
- asprintf(string, "debug: %s", msg);
+ pm_asprintf(string, "debug: %s", msg);
break;
case PM_LOG_ERROR:
- asprintf(string, _("error: %s"), msg);
+ pm_asprintf(string, _("error: %s"), msg);
break;
case PM_LOG_WARNING:
- asprintf(string, _("warning: %s"), msg);
+ pm_asprintf(string, _("warning: %s"), msg);
break;
case PM_LOG_FUNCTION:
- asprintf(string, _("function: %s"), msg);
+ pm_asprintf(string, _("function: %s"), msg);
break;
default:
break;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index d85ba7b6..2e77b0c4 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -62,6 +62,7 @@ int yesno(char *fmt, ...);
int noyes(char *fmt, ...);
int pm_printf(pmloglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));
+int pm_asprintf(char **string, const char *format, ...);
int pm_vfprintf(FILE *stream, pmloglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
int pm_vasprintf(char **string, pmloglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));