Skip to content

Commit

Permalink
properly cast integers in -C so that integer overflow doesnt occur
Browse files Browse the repository at this point in the history
fixed a small error detection bug
version bump
  • Loading branch information
Marco Scannadinari committed Feb 22, 2014
1 parent 918e56c commit 0926098
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
22 changes: 11 additions & 11 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for btcwatch 0.1.3.
# Generated by GNU Autoconf 2.69 for btcwatch 0.1.4.
#
# Report bugs to <marco@scannadinari.co.uk>.
#
Expand Down Expand Up @@ -579,9 +579,9 @@ MAKEFLAGS=

# Identity of this package.
PACKAGE_NAME='btcwatch'
PACKAGE_TARNAME='btcwatch-0.1.3'
PACKAGE_VERSION='0.1.3'
PACKAGE_STRING='btcwatch 0.1.3'
PACKAGE_TARNAME='btcwatch-0.1.4'
PACKAGE_VERSION='0.1.4'
PACKAGE_STRING='btcwatch 0.1.4'
PACKAGE_BUGREPORT='marco@scannadinari.co.uk'
PACKAGE_URL='https://github.com/marcoms/btcwatch'

Expand Down Expand Up @@ -1224,7 +1224,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures btcwatch 0.1.3 to adapt to many kinds of systems.
\`configure' configures btcwatch 0.1.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1272,7 +1272,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/btcwatch-0.1.3]
--docdir=DIR documentation root [DATAROOTDIR/doc/btcwatch-0.1.4]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
Expand All @@ -1285,7 +1285,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of btcwatch 0.1.3:";;
short | recursive ) echo "Configuration of btcwatch 0.1.4:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1366,7 +1366,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
btcwatch configure 0.1.3
btcwatch configure 0.1.4
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1668,7 +1668,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by btcwatch $as_me 0.1.3, which was
It was created by btcwatch $as_me 0.1.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -3883,7 +3883,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by btcwatch $as_me 0.1.3, which was
This file was extended by btcwatch $as_me 0.1.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -3928,7 +3928,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
btcwatch config.status 0.1.3
btcwatch config.status 0.1.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([btcwatch], [0.1.3], [marco@scannadinari.co.uk], [btcwatch-0.1.3], [https://github.com/marcoms/btcwatch])
AC_INIT([btcwatch], [0.1.4], [marco@scannadinari.co.uk], [btcwatch-0.1.4], [https://github.com/marcoms/btcwatch])

define([errnf], [echo " configure: error: $1 not found"; exit 1])

Expand Down
2 changes: 1 addition & 1 deletion src/btcutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ noreturn void help(const char *const prog_nm, const char *const topic) {
" -b --buy print buy price\n"
" -c CURRENCY --currency=CURRENCY set conversion currency\n"
" -k [INTERVAL] --keep-monitoring[=INTERVAL] indefinitely monitor the price,\n"
" and wait for INTERVAL seconds each time\n"
" and wait for INTERVAL seconds each time\n"
" -n AMOUNT --amount=AMOUNT set the amount to convert\n"
" -o [BOOLEAN] --colour[=BOOLEAN] enable use of colour\n"
" -p --ping check for a successful JSON response\n"
Expand Down
12 changes: 7 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ int main(int argc, char **argv) {
: "DOWN",

rates.currcy.sign,
((double) (rates.buy - btcstore.buy) / (double) rates.currcy.sf),
((double) ((int32_t) rates.buy - (int32_t) btcstore.buy) / rates.currcy.sf),
rates.currcy.name,
btcstore.buyf,
rates.buyf
Expand All @@ -271,7 +271,7 @@ int main(int argc, char **argv) {
: "DOWN",

rates.currcy.sign,
((double) (rates.sell - btcstore.sell) / (double) rates.currcy.sf),
((double) ((int32_t) rates.sell - (int32_t) btcstore.sell) / rates.currcy.sf),
rates.currcy.name,
btcstore.sellf,
rates.sellf
Expand All @@ -293,7 +293,7 @@ int main(int argc, char **argv) {
? RED("DOWN")
: "DOWN",

((double) (rates.buy - btcstore.buy) / (double) rates.currcy.sf)
((double) ((int32_t) rates.buy - (int32_t) btcstore.buy) / rates.currcy.sf)
);
}

Expand All @@ -311,7 +311,7 @@ int main(int argc, char **argv) {
? RED("DOWN")
: "DOWN",

((double) (rates.sell - btcstore.sell) / (double) rates.currcy.sf)
((double) ((int32_t) rates.sell - (int32_t) btcstore.sell) / rates.currcy.sf)
);
}
}
Expand All @@ -327,7 +327,9 @@ int main(int argc, char **argv) {
find_paths(btcpath, btcpathwf);
found_path = true;
}
if(mkdir(btcpath, S_IRWXU) == -1) error(EXIT_FAILURE, 0, "%s", strerror(errno));

if(mkdir(btcpath, S_IRWXU) == -1 && errno != EEXIST) error(EXIT_FAILURE, errno, "couldn't create ~/.btcwatch");

fp = fopen(btcpathwf, "w");

if(!rates.got || strcmp(rates.currcy.name, currcy)) api_err = btc_fill_rates(&rates, currcy);
Expand Down

0 comments on commit 0926098

Please sign in to comment.