Bug 117183 - strlen() on random pointer
strlen() on random pointer
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: system-config-securitylevel (Show other bugs)
rawhide
All Linux
high Severity medium
: ---
: ---
Assigned To: Brent Fox
:
: 122069 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-01 06:14 EST by d.binderman
Modified: 2007-11-30 17:10 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-05 10:27:02 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
strlen() patch (589 bytes, patch)
2004-03-02 08:06 EST, Robert Vojta
no flags Details | Diff

  None (edit)
Description d.binderman 2004-03-01 06:14:17 EST
Description of problem:

I just tried to compile Core2 Test1 package
system-config-securitylevel-1.3.1-1

The compiler said

1.

lokkit.c(254): remark #592: variable "ret" is used before its value is set

The source code is

        char *ret;
        struct servent *service;

        memset(tmp,'\0', 256);
        service = getservbyport(htons(port->port), port->proto);
        if (service) {
                snprintf(tmp, 255, "%s:%s", service->s_name, port->proto);
        } else {
                snprintf(tmp, 255, "%d:%s", port->port, port->proto);
        }
        ret = calloc((orig ? strlen(orig) : 0) + strlen(ret) + 2,
sizeof(char));

Doing strlen() on uninit memory is deeply unwise.

I'm not sure what the fix is for this.



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Robert Vojta 2004-03-02 08:01:51 EST
> ret = calloc((orig ? strlen(orig) : 0) + strlen(ret) + 2, sizeof(char));

> Doing strlen() on uninit memory is deeply unwise.

  You're right.

> I'm not sure what the fix is for this.

  It's just a mistake ... Brent, please, change the strlen(ret) to the
strlen(tmp) on line 254 in the lokkit.c file.




Comment 2 Robert Vojta 2004-03-02 08:06:26 EST
Created attachment 98182 [details]
strlen() patch

Very simple patch fixing this bug.
Comment 3 Brent Fox 2004-03-05 10:27:02 EST
Should be fixed in system-config-securitylevel-1.3.4-1.  Thanks for
the patch.
Comment 4 Brent Fox 2004-06-24 15:08:05 EDT
*** Bug 122069 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.