Changeset 360

Show
Ignore:
Timestamp:
01/04/00 13:28:03 (15 years ago)
Author:
ucaccsp
Message:

- Cleanup test routines
- Fix various potential buffer overflow problems
- Update copyright notices to welcome in the new millennium
- Previous versions of udp_send() would sometimes return -1 on error, and

would sometimes abort(). We now always return -1 and never abort.

Location:
common/trunk
Files:
34 modified

Legend:

Unmodified
Added
Removed
  • common/trunk/COPYRIGHT

    r16 r360  
    1 Copyright (C) 1995-1999 University College London 
     1Copyright (C) 1995-2000 University College London 
    22All rights reserved. 
    33 
  • common/trunk/MODS

    r358 r360  
    194194        - Changed library name to uclmmbase to be consistent with other libs.    
    195195        - Add RTP_OPT_FILTER_MY_PACKETS 
     196        - Cleanup test routines 
     197        - Fix various potential buffer overflow problems 
     198        - Update copyright notices to welcome in the new millennium 
     199        - Previous versions of udp_send() would sometimes return -1 on error,  
     200          and would sometimes abort(). We now always return -1 and never abort. 
     201 
    196202 
    197203Still to do... 
  • common/trunk/configure

    r357 r360  
    17261726if test "$GCC" = yes 
    17271727then 
    1728         CFLAGS="$CFLAGS -W -Wall -Wbad-function-cast -Wmissing-prototypes -Werror" 
     1728        CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-declarations -Werror" 
    17291729        if test -f .devel 
    17301730        then 
     
    17651765# If more files than mbus.c use vsnprintf, split it out into 
    17661766# vsnprintf.c and add it to AC_REPLACE_FUNCS 
    1767 echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6 
    1768 echo "configure:1769: checking for vsnprintf" >&5 
    1769 if eval "test \"`echo '$''{'ac_cv_func_vsnprintf'+set}'`\" = set"; then 
    1770   echo $ac_n "(cached) $ac_c" 1>&6 
    1771 else 
    1772   cat > conftest.$ac_ext <<EOF 
    1773 #line 1774 "configure" 
    1774 #include "confdefs.h" 
    1775 /* System header to define __stub macros and hopefully few prototypes, 
    1776     which can conflict with char vsnprintf(); below.  */ 
    1777 #include <assert.h> 
    1778 /* Override any gcc2 internal prototype to avoid an error.  */ 
    1779 /* We use char because int might match the return type of a gcc2 
    1780     builtin and then its argument prototype would still apply.  */ 
    1781 char vsnprintf(); 
    1782  
    1783 int main() { 
    1784  
    1785 /* The GNU C library defines this for functions which it implements 
    1786     to always fail with ENOSYS.  Some functions are actually named 
    1787     something starting with __ and the normal name is an alias.  */ 
    1788 #if defined (__stub_vsnprintf) || defined (__stub___vsnprintf) 
    1789 choke me 
    1790 #else 
    1791 vsnprintf(); 
    1792 #endif 
    1793  
    1794 ; return 0; } 
    1795 EOF 
    1796 if { (eval echo configure:1797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
    1797   rm -rf conftest* 
    1798   eval "ac_cv_func_vsnprintf=yes" 
    1799 else 
    1800   echo "configure: failed program was:" >&5 
    1801   cat conftest.$ac_ext >&5 
    1802   rm -rf conftest* 
    1803   eval "ac_cv_func_vsnprintf=no" 
    1804 fi 
    1805 rm -f conftest* 
    1806 fi 
    1807  
    1808 if eval "test \"`echo '$ac_cv_func_'vsnprintf`\" = yes"; then 
    1809   echo "$ac_t""yes" 1>&6 
    1810   : 
    1811 else 
    1812   echo "$ac_t""no" 1>&6 
    1813 cat >> confdefs.h <<\EOF 
    1814 #define NEED_VSNPRINTF 1 
    1815 EOF 
    1816  
    1817 fi 
    1818  
    1819  
    1820 # If inet_aton is actually needed somewhere, split it out into 
    1821 # inet_aton.c and add it to AC_REPLACE_FUNCS 
    1822  
    1823 for ac_func in inet_pton inet_ntop 
     1767for ac_func in vsnprintf 
    18241768do 
    18251769echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 
    1826 echo "configure:1827: checking for $ac_func" >&5 
     1770echo "configure:1771: checking for $ac_func" >&5 
    18271771if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then 
    18281772  echo $ac_n "(cached) $ac_c" 1>&6 
    18291773else 
    18301774  cat > conftest.$ac_ext <<EOF 
    1831 #line 1832 "configure" 
     1775#line 1776 "configure" 
    18321776#include "confdefs.h" 
    18331777/* System header to define __stub macros and hopefully few prototypes, 
     
    18521796; return 0; } 
    18531797EOF 
    1854 if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
     1798if { (eval echo configure:1799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
    18551799  rm -rf conftest* 
    18561800  eval "ac_cv_func_$ac_func=yes" 
     
    18731817else 
    18741818  echo "$ac_t""no" 1>&6 
     1819fi 
     1820done 
     1821 
     1822 
     1823# If inet_aton is actually needed somewhere, split it out into 
     1824# inet_aton.c and add it to AC_REPLACE_FUNCS 
     1825 
     1826for ac_func in inet_pton inet_ntop 
     1827do 
     1828echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 
     1829echo "configure:1830: checking for $ac_func" >&5 
     1830if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then 
     1831  echo $ac_n "(cached) $ac_c" 1>&6 
     1832else 
     1833  cat > conftest.$ac_ext <<EOF 
     1834#line 1835 "configure" 
     1835#include "confdefs.h" 
     1836/* System header to define __stub macros and hopefully few prototypes, 
     1837    which can conflict with char $ac_func(); below.  */ 
     1838#include <assert.h> 
     1839/* Override any gcc2 internal prototype to avoid an error.  */ 
     1840/* We use char because int might match the return type of a gcc2 
     1841    builtin and then its argument prototype would still apply.  */ 
     1842char $ac_func(); 
     1843 
     1844int main() { 
     1845 
     1846/* The GNU C library defines this for functions which it implements 
     1847    to always fail with ENOSYS.  Some functions are actually named 
     1848    something starting with __ and the normal name is an alias.  */ 
     1849#if defined (__stub_$ac_func) || defined (__stub___$ac_func) 
     1850choke me 
     1851#else 
     1852$ac_func(); 
     1853#endif 
     1854 
     1855; return 0; } 
     1856EOF 
     1857if { (eval echo configure:1858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
     1858  rm -rf conftest* 
     1859  eval "ac_cv_func_$ac_func=yes" 
     1860else 
     1861  echo "configure: failed program was:" >&5 
     1862  cat conftest.$ac_ext >&5 
     1863  rm -rf conftest* 
     1864  eval "ac_cv_func_$ac_func=no" 
     1865fi 
     1866rm -f conftest* 
     1867fi 
     1868 
     1869if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then 
     1870  echo "$ac_t""yes" 1>&6 
     1871    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 
     1872  cat >> confdefs.h <<EOF 
     1873#define $ac_tr_func 1 
     1874EOF 
     1875  
     1876else 
     1877  echo "$ac_t""no" 1>&6 
    18751878LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" 
    18761879fi 
     
    18811884 
    18821885echo $ac_n "checking for library containing socket""... $ac_c" 1>&6 
    1883 echo "configure:1884: checking for library containing socket" >&5 
     1886echo "configure:1887: checking for library containing socket" >&5 
    18841887if eval "test \"`echo '$''{'ac_cv_search_socket'+set}'`\" = set"; then 
    18851888  echo $ac_n "(cached) $ac_c" 1>&6 
     
    18881891ac_cv_search_socket="no" 
    18891892cat > conftest.$ac_ext <<EOF 
    1890 #line 1891 "configure" 
     1893#line 1894 "configure" 
    18911894#include "confdefs.h" 
    18921895/* Override any gcc2 internal prototype to avoid an error.  */ 
     
    18991902; return 0; } 
    19001903EOF 
    1901 if { (eval echo configure:1902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
     1904if { (eval echo configure:1905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
    19021905  rm -rf conftest* 
    19031906  ac_cv_search_socket="none required" 
     
    19101913LIBS="-l$i  $ac_func_search_save_LIBS" 
    19111914cat > conftest.$ac_ext <<EOF 
    1912 #line 1913 "configure" 
     1915#line 1916 "configure" 
    19131916#include "confdefs.h" 
    19141917/* Override any gcc2 internal prototype to avoid an error.  */ 
     
    19211924; return 0; } 
    19221925EOF 
    1923 if { (eval echo configure:1924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
     1926if { (eval echo configure:1927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
    19241927  rm -rf conftest* 
    19251928  ac_cv_search_socket="-l$i" 
     
    19431946 
    19441947echo $ac_n "checking for library containing inet_addr""... $ac_c" 1>&6 
    1945 echo "configure:1946: checking for library containing inet_addr" >&5 
     1948echo "configure:1949: checking for library containing inet_addr" >&5 
    19461949if eval "test \"`echo '$''{'ac_cv_search_inet_addr'+set}'`\" = set"; then 
    19471950  echo $ac_n "(cached) $ac_c" 1>&6 
     
    19501953ac_cv_search_inet_addr="no" 
    19511954cat > conftest.$ac_ext <<EOF 
    1952 #line 1953 "configure" 
     1955#line 1956 "configure" 
    19531956#include "confdefs.h" 
    19541957/* Override any gcc2 internal prototype to avoid an error.  */ 
     
    19611964; return 0; } 
    19621965EOF 
    1963 if { (eval echo configure:1964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
     1966if { (eval echo configure:1967: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
    19641967  rm -rf conftest* 
    19651968  ac_cv_search_inet_addr="none required" 
     
    19721975LIBS="-l$i  $ac_func_search_save_LIBS" 
    19731976cat > conftest.$ac_ext <<EOF 
    1974 #line 1975 "configure" 
     1977#line 1978 "configure" 
    19751978#include "confdefs.h" 
    19761979/* Override any gcc2 internal prototype to avoid an error.  */ 
     
    19831986; return 0; } 
    19841987EOF 
    1985 if { (eval echo configure:1986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
     1988if { (eval echo configure:1989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 
    19861989  rm -rf conftest* 
    19871990  ac_cv_search_inet_addr="-l$i" 
     
    20992102 
    21002103echo $ac_n "checking for getipnodebyname in <netdb.h>""... $ac_c" 1>&6 
    2101 echo "configure:2102: checking for getipnodebyname in <netdb.h>" >&5 
     2104echo "configure:2105: checking for getipnodebyname in <netdb.h>" >&5 
    21022105if eval "test \"`echo '$''{'ucl_cv_getipnodebyname_in_netdb_h'+set}'`\" = set"; then 
    21032106  echo $ac_n "(cached) $ac_c" 1>&6 
    21042107else 
    21052108  cat > conftest.$ac_ext <<EOF 
    2106 #line 2107 "configure" 
     2109#line 2110 "configure" 
    21072110#include "confdefs.h" 
    21082111#include <netdb.h> 
     
    21332136ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` 
    21342137echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 
    2135 echo "configure:2136: checking for $ac_hdr" >&5 
     2138echo "configure:2139: checking for $ac_hdr" >&5 
    21362139if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then 
    21372140  echo $ac_n "(cached) $ac_c" 1>&6 
    21382141else 
    21392142  cat > conftest.$ac_ext <<EOF 
    2140 #line 2141 "configure" 
     2143#line 2144 "configure" 
    21412144#include "confdefs.h" 
    21422145#include <$ac_hdr> 
    21432146EOF 
    21442147ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 
    2145 { (eval echo configure:2146: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 
     2148{ (eval echo configure:2149: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 
    21462149ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 
    21472150if test -z "$ac_err"; then 
     
    21712174 
    21722175echo $ac_n "checking for struct addrinfo in <netdb.h>""... $ac_c" 1>&6 
    2173 echo "configure:2174: checking for struct addrinfo in <netdb.h>" >&5 
     2176echo "configure:2177: checking for struct addrinfo in <netdb.h>" >&5 
    21742177if eval "test \"`echo '$''{'ucl_cv_st_addrinfo_in_netdb_h'+set}'`\" = set"; then 
    21752178  echo $ac_n "(cached) $ac_c" 1>&6 
    21762179else 
    21772180  cat > conftest.$ac_ext <<EOF 
    2178 #line 2179 "configure" 
     2181#line 2182 "configure" 
    21792182#include "confdefs.h" 
    21802183#include <netdb.h> 
     
    22022205 
    22032206echo $ac_n "checking for sin6_len in struct sockaddr_in6""... $ac_c" 1>&6 
    2204 echo "configure:2205: checking for sin6_len in struct sockaddr_in6" >&5 
     2207echo "configure:2208: checking for sin6_len in struct sockaddr_in6" >&5 
    22052208if eval "test \"`echo '$''{'ucl_cv_sin6_len'+set}'`\" = set"; then 
    22062209  echo $ac_n "(cached) $ac_c" 1>&6 
    22072210else 
    22082211  cat > conftest.$ac_ext <<EOF 
    2209 #line 2210 "configure" 
     2212#line 2213 "configure" 
    22102213#include "confdefs.h" 
    22112214 
     
    22232226; return 0; } 
    22242227EOF 
    2225 if { (eval echo configure:2226: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then 
     2228if { (eval echo configure:2229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then 
    22262229  rm -rf conftest* 
    22272230  ucl_cv_sin6_len=yes 
  • common/trunk/configure.in

    r357 r360  
    100100if test "$GCC" = yes 
    101101then 
    102         CFLAGS="$CFLAGS -W -Wall -Wbad-function-cast -Wmissing-prototypes -Werror" 
     102        CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-declarations -Werror" 
    103103        if test -f .devel 
    104104        then 
     
    112112# If more files than mbus.c use vsnprintf, split it out into 
    113113# vsnprintf.c and add it to AC_REPLACE_FUNCS 
    114 AC_CHECK_FUNC(vsnprintf,,AC_DEFINE(NEED_VSNPRINTF)) 
     114AC_CHECK_FUNCS(vsnprintf) 
    115115 
    116116# If inet_aton is actually needed somewhere, split it out into 
  • common/trunk/src/Makefile.in

    r359 r360  
    3131 
    3232version.h:      VERSION 
    33         sed -e 's/.*/#define CCL_VERSION "CCL v& $(HOST)"/' VERSION > version.h 
     33        sed -e 's/.*/#define CCL_VERSION "v&"/' VERSION > version.h 
    3434 
    3535.c.o: 
  • common/trunk/src/acconfig.h

    r351 r360  
    1717 
    1818/* 
    19  * Define this if your C library doesn't have vsnprintf. 
     19 * Define this if your C library has vsnprintf. 
    2020 */ 
    21 #undef NEED_VSNPRINTF 
     21#undef HAVE_VSNPRINTF 
    2222 
    2323 
  • common/trunk/src/base64.c

    r178 r360  
    66 * from version 2.7 of the Bellcore metamail package. 
    77 * 
    8  * Copyright (c) 1998 University College London 
     8 * Copyright (c) 1998-2000 University College London 
    99 * All rights reserved. 
    1010 * 
  • common/trunk/src/base64.h

    r14 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1998 University College London 
     5 * Copyright (c) 1998-2000 University College London 
    66 * All rights reserved. 
    77 * 
  • common/trunk/src/config.h.in

    r351 r360  
    3737 
    3838/* 
    39  * Define this if your C library doesn't have vsnprintf. 
    40  */ 
    41 #undef NEED_VSNPRINTF 
    42  
    43 /* 
    4439 * If you don't have these types in <inttypes.h>, #define these to be 
    4540 * the types you do have. 
     
    7873#undef HAVE_INET_PTON 
    7974 
     75/* Define if you have the vsnprintf function.  */ 
     76#undef HAVE_VSNPRINTF 
     77 
    8078/* Define if you have the <inttypes.h> header file.  */ 
    8179#undef HAVE_INTTYPES_H 
  • common/trunk/src/config_unix.h

    r357 r360  
    77 *  $Date$ 
    88 * 
    9  * Copyright (c) 1995-98 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
     
    7474#include <netdb.h> 
    7575#include <arpa/inet.h> 
    76 extern int h_errno; 
    7776 
    7877#ifdef HAVE_STDINT_H 
  • common/trunk/src/config_win32.h

    r342 r360  
    77 *  $Date$ 
    88 * 
    9  * Copyright (c) 1995-98 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
  • common/trunk/src/debug.c

    r332 r360  
    1111 * $Date$ 
    1212 * 
    13  * Copyright (c) 1995-97 University College London 
     13 * Copyright (c) 1995-2000 University College London 
    1414 * All rights reserved. 
    1515 * 
  • common/trunk/src/debug.h

    r334 r360  
    77 * $Date$ 
    88 * 
    9  * Copyright (c) 1995-97 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
  • common/trunk/src/hmac.c

    r11 r360  
    55 * HMAC message authentication (RFC2104) 
    66 *  
    7  * Copyright (c) 1998 University College London 
     7 * Copyright (c) 1998-2000 University College London 
    88 * All rights reserved. 
    99 * 
  • common/trunk/src/hmac.h

    r11 r360  
    55 * HMAC message authentication (RFC2104) 
    66 *  
    7  * Copyright (c) 1998 University College London 
     7 * Copyright (c) 1998-2000 University College London 
    88 * All rights reserved. 
    99 * 
  • common/trunk/src/mbus.c

    r352 r360  
    55 *           Markus Germeier 
    66 *  
    7  * Copyright (c) 1997-99 University College London 
     7 * Copyright (c) 1997-2000 University College London 
    88 * All rights reserved. 
    99 * 
     
    5454#define MBUS_MAX_QLEN       50 /* Number of messages we can queue with mbus_qmsg() */ 
    5555 
    56 #ifdef NEED_VSNPRINTF 
    57 static int vsnprintf(char *s, int buf_size, const char *format, va_list ap) 
     56#ifndef HAVE_VSNPRINTF 
     57int vsnprintf(char *s, size_t buf_size, const char *format, va_list ap) 
    5858{ 
    5959        /* Quick hack replacement for vsnprintf... note that this */ 
     
    149149        /* iff the addresses are identical (except, possibly, for order */ 
    150150        /* of the elements.                                             */ 
    151         char    *y = NULL, c='\0'; 
     151        char    *y = NULL;  
     152        char     c='\0'; 
    152153        char    *a_orig, *b_orig; 
    153154 
  • common/trunk/src/mbus.h

    r294 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1997,1998 University College London 
     5 * Copyright (c) 1997-2000 University College London 
    66 * All rights reserved. 
    77 * 
  • common/trunk/src/mbus_config.c

    r350 r360  
    55 *           Markus Germeier 
    66 *  
    7  * Copyright (c) 1999 University College London 
     7 * Copyright (c) 1999-2000 University College London 
    88 * All rights reserved. 
    99 * 
  • common/trunk/src/mbus_config.h

    r348 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 * 
  • common/trunk/src/memory.c

    r260 r360  
    77 * $Date$ 
    88 * 
    9  * Copyright (c) 1995-98 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
  • common/trunk/src/memory.h

    r205 r360  
    77 * $Date$ 
    88 * 
    9  * Copyright (c) 1995-98 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
  • common/trunk/src/net_udp.c

    r351 r360  
    44* MODIFIED: Orion Hodson & Piers O'Hanlon 
    55*  
    6 * Copyright (c) 1998-99 University College London 
     6* Copyright (c) 1998-2000 University College London 
    77* All rights reserved. 
    88* 
     
    273273{ 
    274274        struct sockaddr_in      s_in; 
    275         int                     ret; 
    276275         
    277276        assert(s != NULL); 
     
    283282        s_in.sin_addr.s_addr = s->addr4.s_addr; 
    284283        s_in.sin_port        = htons(s->tx_port); 
    285         if ((ret = sendto(s->fd, buffer, buflen, 0, (struct sockaddr *) &s_in, sizeof(s_in))) < 0) { 
    286                 if (errno != ECONNREFUSED) { 
    287                         socket_error("sendto"); 
    288                 } 
    289         } 
    290         return ret; 
     284        return sendto(s->fd, buffer, buflen, 0, (struct sockaddr *) &s_in, sizeof(s_in)); 
    291285} 
    292286 
     
    305299        assert(hent->h_addrtype == AF_INET); 
    306300        memcpy(&iaddr.s_addr, hent->h_addr, sizeof(iaddr.s_addr)); 
    307         strcpy(hname, inet_ntoa(iaddr)); 
     301        strncpy(hname, inet_ntoa(iaddr), MAXHOSTNAMELEN); 
    308302        return hname; 
    309303} 
     
    428422#ifdef HAVE_IPv6 
    429423        struct sockaddr_in6     s_in; 
    430         int                     ret; 
    431424         
    432425        assert(s != NULL); 
     
    442435        s_in.sin6_len    = sizeof(s_in); 
    443436#endif 
    444         if ((ret = sendto(s->fd, buffer, buflen, 0, (struct sockaddr *) &s_in, sizeof(s_in))) < 0) { 
    445                 socket_error("udp_send6"); 
    446         } 
    447         return ret; 
     437        return sendto(s->fd, buffer, buflen, 0, (struct sockaddr *) &s_in, sizeof(s_in)); 
    448438#else 
    449439        UNUSED(s); 
     
    595585        /* we receive, this function becomes protocol independent.           */ 
    596586        int             len; 
    597          
     587 
    598588        assert(buffer != NULL); 
    599589        assert(buflen > 0); 
    600          
     590 
    601591        len = recvfrom(s->fd, buffer, buflen, 0, 0, 0); 
    602592        if (len > 0) { 
     
    645635        return NULL; 
    646636} 
     637 
  • common/trunk/src/net_udp.h

    r314 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1998-99 University College London 
     5 * Copyright (c) 1998-2000 University College London 
    66 * All rights reserved. 
    77 * 
  • common/trunk/src/rtp.c

    r359 r360  
    1515 * $Date$ 
    1616 *  
    17  * Copyright (c) 1998-99 University College London 
     17 * Copyright (c) 1998-2000 University College London 
    1818 * All rights reserved. 
    1919 * 
     
    774774} 
    775775 
     776#define MAXCNAMELEN     255 
     777 
    776778static char *get_cname(socket_udp *s) 
    777779{ 
     
    784786#endif 
    785787 
    786         cname = (char *) xmalloc(MAXHOSTNAMELEN + 10); 
     788        cname = (char *) xmalloc(MAXCNAMELEN + 1); 
    787789        cname[0] = '\0'; 
    788790 
     
    795797#endif 
    796798        if (uname != NULL) { 
    797                 sprintf(cname, "%s@", uname); 
     799                snprintf(cname, MAXCNAMELEN, "%s@", uname); 
    798800        } 
    799801 
    800802        /* Now the hostname. Must be dotted-quad IP address. */ 
    801803        hname = udp_host_addr(s); 
    802         strcpy(cname + strlen(cname), hname); 
     804        strncpy(cname + strlen(cname), hname, MAXCNAMELEN - strlen(cname)); 
    803805        xfree(hname); 
    804806        return cname; 
     
    18771879} 
    18781880 
    1879 static int add_sdes_item(uint8_t *buf, int type, const char *val) 
     1881static int add_sdes_item(uint8_t *buf, int buflen, int type, const char *val) 
    18801882{ 
    18811883        /* Fill out an SDES item. It is assumed that the item is a NULL    */ 
     
    18911893        namelen = strlen(val); 
    18921894        shdr->length = namelen; 
    1893         strcpy(shdr->data, val); 
     1895        strncpy(shdr->data, val, buflen - 2); /* The "-2" accounts for the other shdr fields */ 
    18941896        return namelen + 2; 
    18951897} 
     
    19281930        item = rtp_get_sdes(session, ssrc, RTCP_SDES_CNAME); 
    19291931        if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) { 
    1930                 packet += add_sdes_item(packet, RTCP_SDES_CNAME, item); 
     1932                packet += add_sdes_item(packet, remaining_len, RTCP_SDES_CNAME, item); 
    19311933        } 
    19321934 
     
    19341936        item = rtp_get_sdes(session, ssrc, RTCP_SDES_NOTE); 
    19351937        if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) { 
    1936                 packet += add_sdes_item(packet, RTCP_SDES_NOTE, item); 
     1938                packet += add_sdes_item(packet, remaining_len, RTCP_SDES_NOTE, item); 
    19371939        } 
    19381940 
     
    19471949                        case 0: item = rtp_get_sdes(session, ssrc, RTCP_SDES_TOOL); 
    19481950                                if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) { 
    1949                                         packet += add_sdes_item(packet, RTCP_SDES_TOOL, item); 
     1951                                        packet += add_sdes_item(packet, remaining_len, RTCP_SDES_TOOL, item); 
    19501952                                        break; 
    19511953                                } 
    19521954                        case 1: item = rtp_get_sdes(session, ssrc, RTCP_SDES_EMAIL); 
    19531955                                if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) { 
    1954                                         packet += add_sdes_item(packet, RTCP_SDES_EMAIL, item); 
     1956                                        packet += add_sdes_item(packet, remaining_len, RTCP_SDES_EMAIL, item); 
    19551957                                        break; 
    19561958                                } 
    19571959                        case 2: item = rtp_get_sdes(session, ssrc, RTCP_SDES_PHONE); 
    19581960                                if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) { 
    1959                                         packet += add_sdes_item(packet, RTCP_SDES_PHONE, item); 
     1961                                        packet += add_sdes_item(packet, remaining_len, RTCP_SDES_PHONE, item); 
    19601962                                        break; 
    19611963                                } 
    19621964                        case 3: item = rtp_get_sdes(session, ssrc, RTCP_SDES_LOC); 
    19631965                                if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) { 
    1964                                         packet += add_sdes_item(packet, RTCP_SDES_LOC, item); 
     1966                                        packet += add_sdes_item(packet, remaining_len, RTCP_SDES_LOC, item); 
    19651967                                        break; 
    19661968                                } 
     
    19701972                        item = rtp_get_sdes(session, ssrc, RTCP_SDES_NAME); 
    19711973                        if (item != NULL) { 
    1972                                 packet += add_sdes_item(packet, RTCP_SDES_NAME, item); 
     1974                                packet += add_sdes_item(packet, remaining_len, RTCP_SDES_NAME, item); 
    19731975                        } 
    19741976                } 
  • common/trunk/src/rtp.h

    r358 r360  
    66 * $Date$ 
    77 *  
    8  * Copyright (c) 1998-99 University College London 
     8 * Copyright (c) 1998-2000 University College London 
    99 * All rights reserved. 
    1010 * 
  • common/trunk/src/util.c

    r186 r360  
    77 * $Date$ 
    88 * 
    9  * Copyright (c) 1995-97 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
  • common/trunk/src/util.h

    r205 r360  
    77 * $Date$ 
    88 * 
    9  * Copyright (c) 1995-98 University College London 
     9 * Copyright (c) 1995-2000 University College London 
    1010 * All rights reserved. 
    1111 * 
  • common/trunk/tests/test.c

    r178 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 * 
     
    4242#include "test_md5.h" 
    4343 
    44 int main() 
     44int main(int argc, char *argv[]) 
    4545{ 
    46         printf("Test suite for %s\n", CCL_VERSION); 
     46        UNUSED(argc); 
     47        UNUSED(argv); 
     48        printf("Testing common multimedia library %s\n", CCL_VERSION); 
    4749        test_base64(); 
    4850        test_des(); 
  • common/trunk/tests/test_base64.c

    r178 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 * 
     
    5252        } 
    5353 
    54         printf("  base64 encode: "); fflush(stdout); 
     54        printf("Base64 encode... "); fflush(stdout); 
    5555        i = base64encode(input, strlen(input), output, 100); 
    5656        if ((i != 16) || (strncmp(output, "SGVsbG8sIHdvcmxk", i) != 0)) { 
    57                 printf("failed\n"); 
    58         } else { 
    59                 printf("success\n"); 
     57                printf("fail\n"); 
     58                abort(); 
    6059        } 
     60        printf("pass\n"); 
    6161 
    62         printf("  base64 decode: "); fflush(stdout); 
     62        printf("Base64 decode... "); fflush(stdout); 
    6363        i = base64decode(output, i, decode, 100); 
    6464        if ((i != 12) || (strncmp(decode, "Hello, world", i) != 0)) { 
    65                 printf("failed\n"); 
    66         } else { 
    67                 printf("success\n"); 
     65                printf("fail\n"); 
     66                abort(); 
    6867        } 
     68        printf("pass\n"); 
    6969} 
    7070 
  • common/trunk/tests/test_base64.h

    r178 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 * 
  • common/trunk/tests/test_des.c

    r162 r360  
    99 * All rights reserved. 
    1010 *  
    11  * Copyright (c) 1999 University College London 
     11 * Copyright (c) 1999-2000 University College London 
    1212 * All rights reserved. 
    1313 * 
     
    217217        unsigned char   cbc_buffer[32], cbc_iv_buf[8]; 
    218218 
     219        printf("DES ECB......... "); fflush(stdout); 
    219220        for (i = 0; i < NUM_TESTS; i++) { 
    220                 printf("  DES ECB %2d: ", i); fflush(stdout); 
    221221                for (j = 0; j < 8; j++) { 
    222222                        key[j]   = key_data[i][j]; 
     
    227227                qfDES_ECB_d(key, buffer, 8); 
    228228                if (memcmp(buffer, plain, 8) != 0) { 
    229                         printf("decrypt failed\n"); 
     229                        printf("fail\n"); 
    230230                        abort(); 
    231231                } 
     
    233233                qfDES_ECB_e(key, buffer, 8); 
    234234                if (memcmp(buffer, crypt, 8) != 0) { 
    235                         printf("encrypt failed\n"); 
     235                        printf("fail\n"); 
    236236                        abort(); 
    237237                } 
    238238                qfDES_ECB_d(key, buffer, 8); 
    239239                if (memcmp(buffer, plain, 8) != 0) { 
    240                         printf("decrypt failed\n"); 
     240                        printf("fail\n"); 
    241241                        abort(); 
    242242                } 
    243                 printf("success\n"); 
    244243        } 
    245  
    246         printf("  DES CBC: "); fflush(stdout); 
     244        printf("pass\n"); 
     245 
     246        printf("DES CBC......... "); fflush(stdout); 
    247247        memcpy(cbc_buffer, cbc_data, 32); 
    248248        memcpy(cbc_iv_buf, cbc_iv, 8); 
    249249        qfDES_CBC_e(cbc_key, cbc_buffer, 32, cbc_iv_buf); 
    250250        if (memcmp(cbc_buffer, cbc_ok, 32) != 0) { 
    251                 printf("encrypt failed\n"); 
     251                printf("fail\n"); 
    252252                abort(); 
    253253        } 
     
    255255        qfDES_CBC_d(cbc_key, cbc_buffer, 32, cbc_iv_buf); 
    256256        if (memcmp(cbc_buffer, cbc_data, 32) != 0) { 
    257                 printf("decrypt failed\n"); 
     257                printf("fail\n"); 
    258258                abort(); 
    259259        } 
    260         printf("success\n"); 
     260        printf("pass\n"); 
    261261} 
    262262 
    263  
    264 /*****************************************************************************/ 
    265 #ifdef NDEF 
    266  
    267 main() 
    268         { 
    269         int i,j; 
    270         des_cblock in,out,outin; 
    271         des_key_schedule ks; 
    272         unsigned char cbc_in[40],cbc_out[40]; 
    273         unsigned long cs; 
    274         unsigned char qret[4][4]; 
    275         unsigned long lqret[4]; 
    276         char *str; 
    277  
    278         printf("Doing cbc\n"); 
    279         if ((j=key_sched((C_Block *)cbc_key,ks)) != 0) 
    280                 printf("Key error %2d:%d\n",i+1,j); 
    281         bzero(cbc_out,40); 
    282         bzero(cbc_in,40); 
    283         des_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, 
    284                 (long)strlen(cbc_data),ks,(C_Block *)cbc_iv,DES_ENCRYPT); 
    285         if (bcmp(cbc_out,cbc_ok,32) != 0) 
    286                 printf("cbc_encrypt encrypt error\n"); 
    287         des_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, 
    288                 (long)strlen(cbc_data),ks,(C_Block *)cbc_iv,DES_DECRYPT); 
    289         if (bcmp(cbc_in,cbc_data,32) != 0) 
    290                 printf("cbc_encrypt decrypt error\n"); 
    291  
    292         printf("Doing pcbc\n"); 
    293         if ((j=key_sched((C_Block *)cbc_key,ks)) != 0) 
    294                 printf("Key error %2d:%d\n",i+1,j); 
    295         bzero(cbc_out,40); 
    296         bzero(cbc_in,40); 
    297         des_pcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, 
    298                 (long)strlen(cbc_data),ks,(C_Block *)cbc_iv,DES_ENCRYPT); 
    299         if (bcmp(cbc_out,pcbc_ok,32) != 0) 
    300                 printf("pcbc_encrypt encrypt error\n"); 
    301         des_pcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, 
    302                 (long)strlen(cbc_data),ks,(C_Block *)cbc_iv,DES_DECRYPT); 
    303         if (bcmp(cbc_in,cbc_data,32) != 0) 
    304                 printf("pcbc_encrypt decrypt error\n"); 
    305  
    306         printf("Doing cfb\n"); 
    307         key_sched((C_Block *)cfb_key,ks); 
    308         bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv)); 
    309         des_cfb_encrypt(cfb_plain,cfb_buf1,8,(long)sizeof(cfb_plain),ks, 
    310                 (C_Block *)cfb_tmp,DES_ENCRYPT); 
    311         if (bcmp(cfb_cipher,cfb_buf1,sizeof(cfb_buf1)) != 0) 
    312                 printf("cfb_encrypt encrypt error\n"); 
    313         bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv)); 
    314         des_cfb_encrypt(cfb_buf1,cfb_buf2,8,(long)sizeof(cfb_buf1),ks, 
    315                 (C_Block *)cfb_tmp,DES_DECRYPT); 
    316         if (bcmp(cfb_plain,cfb_buf2,sizeof(cfb_buf2)) != 0) 
    317                 printf("cfb_encrypt decrypt error\n"); 
    318  
    319         bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv)); 
    320         for (i=0; i<sizeof(cfb_plain); i++) 
    321                 des_cfb_encrypt(&(cfb_plain[i]),&(cfb_buf1[i]), 
    322                         8,(long)1,ks,(C_Block *)cfb_tmp,DES_ENCRYPT); 
    323         if (bcmp(cfb_cipher,cfb_buf1,sizeof(cfb_buf1)) != 0) 
    324                 printf("cfb_encrypt small encrypt error\n"); 
    325  
    326         bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv)); 
    327         for (i=0; i<sizeof(cfb_plain); i++) 
    328                 des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]), 
    329                         8,(long)1,ks,(C_Block *)cfb_tmp,DES_DECRYPT); 
    330         if (bcmp(cfb_plain,cfb_buf2,sizeof(cfb_buf2)) != 0) 
    331                 printf("cfb_encrypt small decrypt error\n"); 
    332  
    333         printf("Doing ofb\n"); 
    334         key_sched((C_Block *)ofb_key,ks); 
    335         bcopy(ofb_iv,ofb_tmp,sizeof(ofb_iv)); 
    336         des_ofb_encrypt(ofb_plain,ofb_buf1,64,(long)sizeof(cfb_plain)/8,ks, 
    337                 (C_Block *)ofb_tmp); 
    338         if (bcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 
    339                 printf("ofb_encrypt encrypt error\n"); 
    340         bcopy(ofb_iv,ofb_tmp,sizeof(ofb_iv)); 
    341         des_ofb_encrypt(ofb_buf1,ofb_buf2,64,(long)sizeof(ofb_buf1)/8,ks, 
    342                 (C_Block *)ofb_tmp); 
    343         if (bcmp(ofb_plain,ofb_buf2,sizeof(ofb_buf2)) != 0) 
    344                 printf("ofb_encrypt decrypt error\n"); 
    345  
    346         printf("Doing cbc_cksum\n"); 
    347         des_cbc_cksum((C_Block *)cbc_data,(C_Block *)cbc_out, 
    348                 (long)strlen(cbc_data),ks,(C_Block *)cbc_iv); 
    349         if (bcmp(cbc_out,cksum_ok,8) != 0) 
    350                 printf("cbc_cksum error\n"); 
    351  
    352         printf("Doing quad_cksum\n"); 
    353         cs=quad_cksum((C_Block *)cbc_data,(C_Block *)qret, 
    354                 (long)strlen(cbc_data),2,(C_Block *)cbc_iv); 
    355         for (i=0; i<4; i++) 
    356                 { 
    357                 lqret[i]=0; 
    358                 bcopy(&(qret[i][0]),&(lqret[i]),4); 
    359                 } 
    360         { /* Big-endian fix */ 
    361         static unsigned long l=1; 
    362         static unsigned char *c=(unsigned char *)&l; 
    363         unsigned long ll; 
    364  
    365         if (!c[0]) 
    366                 { 
    367                 ll=lqret[0]^lqret[3]; 
    368                 lqret[0]^=ll; 
    369                 lqret[3]^=ll; 
    370                 ll=lqret[1]^lqret[2]; 
    371                 lqret[1]^=ll; 
    372                 lqret[2]^=ll; 
    373                 } 
    374         } 
    375         if (cs != 0x70d7a63a) 
    376                 printf("quad_cksum error, ret %08x should be 70d7a63a\n",cs); 
    377         if (lqret[0] != 0x327eba8d) 
    378                 printf("quad_cksum error, out[0] %08x is not %08x\n", 
    379                         lqret[0],0x327eba8d); 
    380         if (lqret[1] != 0x201a49cc) 
    381                 printf("quad_cksum error, out[1] %08x is not %08x\n", 
    382                         lqret[1],0x201a49cc); 
    383         if (lqret[2] != 0x70d7a63a) 
    384                 printf("quad_cksum error, out[2] %08x is not %08x\n", 
    385                         lqret[2],0x70d7a63a); 
    386         if (lqret[3] != 0x501c2c26) 
    387                 printf("quad_cksum error, out[3] %08x is not %08x\n", 
    388                         lqret[3],0x501c2c26); 
    389  
    390         printf("input word alignment test"); 
    391         for (i=0; i<4; i++) 
    392                 { 
    393                 printf(" %d",i); 
    394                 des_cbc_encrypt((C_Block *)&(cbc_out[i]),(C_Block *)cbc_in, 
    395                         (long)strlen(cbc_data),ks,(C_Block *)cbc_iv, 
    396                         DES_ENCRYPT); 
    397                 } 
    398         printf("\noutput word alignment test"); 
    399         for (i=0; i<4; i++) 
    400                 { 
    401                 printf(" %d",i); 
    402                 des_cbc_encrypt((C_Block *)cbc_out,(C_Block *)&(cbc_in[i]), 
    403                         (long)strlen(cbc_data),ks,(C_Block *)cbc_iv, 
    404                         DES_ENCRYPT); 
    405                 } 
    406         printf("\n"); 
    407         printf("fast crypt test "); 
    408         str=crypt("testing","ef"); 
    409         if (strcmp("efGnQx2725bI2",str) != 0) 
    410                 printf("fast crypt error, %x should be efGnQx2725bI2\n",str); 
    411         str=crypt("bca76;23","yA"); 
    412         if (strcmp("yA1Rp/1hZXIJk",str) != 0) 
    413                 printf("fast crypt error, %x should be yA1Rp/1hZXIJk\n",str); 
    414         printf("\n"); 
    415         exit(0); 
    416         } 
    417  
    418 #endif 
    419  
  • common/trunk/tests/test_des.h

    r114 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 * 
  • common/trunk/tests/test_md5.c

    r300 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 * 
     
    6767        int     i, l; 
    6868 
    69         printf("  md5: "); fflush(stdout); 
    70         for (i = 0; i < 100000; i++) { 
     69        printf("MD5............. "); fflush(stdout); 
     70        for (i = 0; i < 10000; i++) { 
    7171                l = lrand48() % 1024; 
    7272                if (do_test(l) == FALSE) { 
    73                         printf("failed with len=%d\n", l); 
    74                         return; 
     73                        printf("fail\n"); 
     74                        abort(); 
    7575                } 
    7676        } 
    77         printf("success\n"); 
     77        printf("pass\n"); 
    7878} 
    7979 
  • common/trunk/tests/test_md5.h

    r93 r360  
    33 * AUTHORS: Colin Perkins 
    44 *  
    5  * Copyright (c) 1999 University College London 
     5 * Copyright (c) 1999-2000 University College London 
    66 * All rights reserved. 
    77 *