LCOV - code coverage report
Current view: top level - strace_git - sysctl.c (source / functions) Hit Total Coverage
Test: strace-4.16.0.69.f1ea-dirty Code Coverage Lines: 0 98 0.0 %
Date: 2017-03-18 00:38:52 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 60 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 1999 Ulrich Drepper <drepper@cygnus.com>
       3                 :            :  * Copyright (c) 2005 Roland McGrath <roland@redhat.com>
       4                 :            :  * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
       5                 :            :  * All rights reserved.
       6                 :            :  *
       7                 :            :  * Redistribution and use in source and binary forms, with or without
       8                 :            :  * modification, are permitted provided that the following conditions
       9                 :            :  * are met:
      10                 :            :  * 1. Redistributions of source code must retain the above copyright
      11                 :            :  *    notice, this list of conditions and the following disclaimer.
      12                 :            :  * 2. Redistributions in binary form must reproduce the above copyright
      13                 :            :  *    notice, this list of conditions and the following disclaimer in the
      14                 :            :  *    documentation and/or other materials provided with the distribution.
      15                 :            :  * 3. The name of the author may not be used to endorse or promote products
      16                 :            :  *    derived from this software without specific prior written permission.
      17                 :            :  *
      18                 :            :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
      19                 :            :  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
      20                 :            :  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
      21                 :            :  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
      22                 :            :  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
      23                 :            :  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      24                 :            :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      25                 :            :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      26                 :            :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      27                 :            :  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      28                 :            :  */
      29                 :            : 
      30                 :            : #include "defs.h"
      31                 :            : 
      32                 :            : #include <linux/sysctl.h>
      33                 :            : 
      34                 :            : #include "xlat/sysctl_root.h"
      35                 :            : #include "xlat/sysctl_kern.h"
      36                 :            : #include "xlat/sysctl_vm.h"
      37                 :            : #include "xlat/sysctl_net.h"
      38                 :            : #include "xlat/sysctl_net_core.h"
      39                 :            : #include "xlat/sysctl_net_unix.h"
      40                 :            : #include "xlat/sysctl_net_ipv4.h"
      41                 :            : #include "xlat/sysctl_net_ipv4_route.h"
      42                 :            : #include "xlat/sysctl_net_ipv4_conf.h"
      43                 :            : #include "xlat/sysctl_net_ipv6.h"
      44                 :            : #include "xlat/sysctl_net_ipv6_route.h"
      45                 :            : 
      46                 :          0 : SYS_FUNC(sysctl)
      47                 :            : {
      48                 :            :         struct __sysctl_args info;
      49                 :            :         int *name;
      50                 :            :         unsigned long size;
      51                 :            : 
      52         [ #  # ]:          0 :         if (umove_or_printaddr(tcp, tcp->u_arg[0], &info))
      53                 :          0 :                 return RVAL_DECODED;
      54                 :            : 
      55                 :          0 :         size = sizeof(int) * (unsigned long) info.nlen;
      56         [ #  # ]:          0 :         name = (size / sizeof(int) != (unsigned long) info.nlen) ? NULL : malloc(size);
      57   [ #  #  #  # ]:          0 :         if (name == NULL ||
      58                 :          0 :             umoven(tcp, (unsigned long) info.name, size, name) < 0) {
      59                 :          0 :                 free(name);
      60         [ #  # ]:          0 :                 if (entering(tcp))
      61                 :          0 :                         tprintf("{%p, %d, %p, %p, %p, %lu}",
      62                 :            :                                 info.name, info.nlen, info.oldval,
      63                 :          0 :                                 info.oldlenp, info.newval, (unsigned long)info.newlen);
      64                 :          0 :                 return RVAL_DECODED;
      65                 :            :         }
      66                 :            : 
      67         [ #  # ]:          0 :         if (entering(tcp)) {
      68                 :          0 :                 unsigned int cnt = 0, max_cnt;
      69                 :            : 
      70                 :          0 :                 tprints("{{");
      71                 :            : 
      72         [ #  # ]:          0 :                 if (info.nlen == 0)
      73                 :          0 :                         goto out;
      74                 :          0 :                 printxval(sysctl_root, name[0], "CTL_???");
      75                 :          0 :                 ++cnt;
      76                 :            : 
      77         [ #  # ]:          0 :                 if (info.nlen == 1)
      78                 :          0 :                         goto out;
      79   [ #  #  #  # ]:          0 :                 switch (name[0]) {
      80                 :            :                 case CTL_KERN:
      81                 :          0 :                         tprints(", ");
      82                 :          0 :                         printxval(sysctl_kern, name[1], "KERN_???");
      83                 :          0 :                         ++cnt;
      84                 :          0 :                         break;
      85                 :            :                 case CTL_VM:
      86                 :          0 :                         tprints(", ");
      87                 :          0 :                         printxval(sysctl_vm, name[1], "VM_???");
      88                 :          0 :                         ++cnt;
      89                 :          0 :                         break;
      90                 :            :                 case CTL_NET:
      91                 :          0 :                         tprints(", ");
      92                 :          0 :                         printxval(sysctl_net, name[1], "NET_???");
      93                 :          0 :                         ++cnt;
      94                 :            : 
      95         [ #  # ]:          0 :                         if (info.nlen == 2)
      96                 :          0 :                                 goto out;
      97   [ #  #  #  #  :          0 :                         switch (name[1]) {
                      # ]
      98                 :            :                         case NET_CORE:
      99                 :          0 :                                 tprints(", ");
     100                 :          0 :                                 printxval(sysctl_net_core, name[2],
     101                 :            :                                           "NET_CORE_???");
     102                 :          0 :                                 break;
     103                 :            :                         case NET_UNIX:
     104                 :          0 :                                 tprints(", ");
     105                 :          0 :                                 printxval(sysctl_net_unix, name[2],
     106                 :            :                                           "NET_UNIX_???");
     107                 :          0 :                                 break;
     108                 :            :                         case NET_IPV4:
     109                 :          0 :                                 tprints(", ");
     110                 :          0 :                                 printxval(sysctl_net_ipv4, name[2],
     111                 :            :                                           "NET_IPV4_???");
     112                 :            : 
     113         [ #  # ]:          0 :                                 if (info.nlen == 3)
     114                 :          0 :                                         goto out;
     115      [ #  #  # ]:          0 :                                 switch (name[2]) {
     116                 :            :                                 case NET_IPV4_ROUTE:
     117                 :          0 :                                         tprints(", ");
     118                 :          0 :                                         printxval(sysctl_net_ipv4_route,
     119                 :          0 :                                                   name[3],
     120                 :            :                                                   "NET_IPV4_ROUTE_???");
     121                 :          0 :                                         break;
     122                 :            :                                 case NET_IPV4_CONF:
     123                 :          0 :                                         tprints(", ");
     124                 :          0 :                                         printxval(sysctl_net_ipv4_conf,
     125                 :          0 :                                                   name[3],
     126                 :            :                                                   "NET_IPV4_CONF_???");
     127                 :          0 :                                         break;
     128                 :            :                                 default:
     129                 :          0 :                                         goto out;
     130                 :            :                                 }
     131                 :          0 :                                 break;
     132                 :            :                         case NET_IPV6:
     133                 :          0 :                                 tprints(", ");
     134                 :          0 :                                 printxval(sysctl_net_ipv6, name[2],
     135                 :            :                                           "NET_IPV6_???");
     136                 :            : 
     137         [ #  # ]:          0 :                                 if (info.nlen == 3)
     138                 :          0 :                                         goto out;
     139         [ #  # ]:          0 :                                 switch (name[2]) {
     140                 :            :                                 case NET_IPV6_ROUTE:
     141                 :          0 :                                         tprints(", ");
     142                 :          0 :                                         printxval(sysctl_net_ipv6_route,
     143                 :          0 :                                                   name[3],
     144                 :            :                                                   "NET_IPV6_ROUTE_???");
     145                 :          0 :                                         break;
     146                 :            :                                 default:
     147                 :          0 :                                         goto out;
     148                 :            :                                 }
     149                 :          0 :                                 break;
     150                 :            :                         default:
     151                 :          0 :                                 goto out;
     152                 :            :                         }
     153                 :          0 :                         break;
     154                 :            :                 default:
     155                 :          0 :                         goto out;
     156                 :            :                 }
     157                 :            :         out:
     158                 :          0 :                 max_cnt = info.nlen;
     159 [ #  # ][ #  # ]:          0 :                 if (abbrev(tcp) && max_cnt > max_strlen)
     160                 :          0 :                         max_cnt = max_strlen;
     161         [ #  # ]:          0 :                 while (cnt < max_cnt)
     162                 :          0 :                         tprintf(", %x", name[cnt++]);
     163         [ #  # ]:          0 :                 if (cnt < (unsigned) info.nlen)
     164                 :          0 :                         tprints(", ...");
     165                 :          0 :                 tprintf("}, %d, ", info.nlen);
     166                 :            :         } else {
     167                 :          0 :                 size_t oldlen = 0;
     168         [ #  # ]:          0 :                 if (info.oldval == NULL) {
     169                 :          0 :                         tprints("NULL");
     170         [ #  # ]:          0 :                 } else if (umove(tcp, ptr_to_kulong(info.oldlenp), &oldlen) >= 0
     171         [ #  # ]:          0 :                            && info.nlen >= 2
     172         [ #  # ]:          0 :                            && ((name[0] == CTL_KERN
     173         [ #  # ]:          0 :                                 && (name[1] == KERN_OSRELEASE
     174         [ #  # ]:          0 :                                     || name[1] == KERN_OSTYPE
     175                 :            :                                         )))) {
     176                 :          0 :                         printpath(tcp, ptr_to_kulong(info.oldval));
     177                 :            :                 } else {
     178                 :          0 :                         tprintf("%p", info.oldval);
     179                 :            :                 }
     180                 :          0 :                 tprintf(", %lu, ", (unsigned long)oldlen);
     181         [ #  # ]:          0 :                 if (info.newval == NULL)
     182                 :          0 :                         tprints("NULL");
     183         [ #  # ]:          0 :                 else if (syserror(tcp))
     184                 :          0 :                         tprintf("%p", info.newval);
     185                 :            :                 else
     186                 :          0 :                         printpath(tcp, ptr_to_kulong(info.newval));
     187                 :          0 :                 tprintf(", %lu", (unsigned long)info.newlen);
     188                 :            :         }
     189                 :            : 
     190                 :          0 :         free(name);
     191                 :          0 :         return 0;
     192                 :            : }

Generated by: LCOV version 1.12