Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:55:29+00:00 2026-05-20T10:55:29+00:00

I have a working exec in php that executes a Jar file and returns

  • 0

I have a working exec in php that executes a Jar file and returns back result:

exec('java -jar Clt.jar ' . $sampleSize . ' ' . $numberOfSamples . ' ' . $randAlgorithm,  $output);

These parameters are checked in Java application in the following way:

int sampleSize = Integer.parseInt(args[0]);
int numberOfSamples = Integer.parseInt(args[1]);
int randGenerator = Integer.parseInt(args[2]);

Now I need to know If I need to check user input, because on PHP page under exec, it says:

When allowing user-supplied data to be passed to this function, use escapeshellarg() or escapeshellcmd() to ensure that users cannot trick the system into executing arbitrary commands.

But in my case, where user input is used only as parameter for application, are there any security risks If I do not check what has user set, apart from that program will not execute if user enters string or floating point number?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:55:29+00:00Added an answer on May 20, 2026 at 10:55 am

    But in my case, where user input is used only as parameter for application

    And this is where you are wrong. exec() is as if you are executing a line on the command-line. What if the users inputs something like: ; rm -rf / && echo. You must escape the input with escapeshellargs(). Or even better use floatval() before passing it to the commandline.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with a string[] array in C# that gets returned from
I have been working on some legacy C++ code that uses variable length structures
I have an execute(String cmd) in a jsp script that calls the exec method
I have a PHP script that's supposed to take in a URL and search
I'm working on a PHP application that links into the Protx VSP Direct payment
I'm working on a PHP script that runs a Python script on the server.
I have recently started working on a legacy application that has most of its
I have been working on a web services related project for about the last
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
We have been working with CVS for years, and frequently find it useful to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.