X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Flib%2Fgetctx-legacy.hc;h=a3ac1be2145ad9c452fdb260104973dedc0882e8;hb=e1f5cbac553962aa8725347509145147103fbe7c;hp=17928c9e3f669a6597aed29e20b38aed9bb67a6d;hpb=cb74f15ef5e31b2c8ecb330542a37808821861ae;p=util-vserver.git diff --git a/util-vserver/lib/getctx-legacy.hc b/util-vserver/lib/getctx-legacy.hc index 17928c9..a3ac1be 100644 --- a/util-vserver/lib/getctx-legacy.hc +++ b/util-vserver/lib/getctx-legacy.hc @@ -45,11 +45,19 @@ vc_X_getctx_legacy(pid_t pid) size_t len; char *pos = 0; - strcpy(status_name, "/proc/"); - len = utilvserver_uint2str(status_name+sizeof("/proc/")-1, - sizeof(status_name)-sizeof("/proc//status")+1, - pid, 10); - strcpy(status_name+sizeof("/proc/")+len-1, "/status"); + if (pid<0 || (uint32_t)(pid)>99999) { + errno = EINVAL; + return 0; + } + + if (pid==0) strcpy(status_name, "/proc/self/status"); + else { + strcpy(status_name, "/proc/"); + len = utilvserver_uint2str(status_name+sizeof("/proc/")-1, + sizeof(status_name)-sizeof("/proc//status")+1, + pid, 10); + strcpy(status_name+sizeof("/proc/")+len-1, "/status"); + } fd = open(status_name, O_RDONLY); if (fd==-1) return VC_NOCTX;