Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 156355 Details for
Bug 226997
udevd read buffer too small.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to use upstream versions of mem_size_mb(), cpu_count(), and running_processes()
udev-proc-cleanup.patch (text/plain), 2.74 KB, created by
George Beshers
on 2007-06-06 14:41:44 UTC
(
hide
)
Description:
Patch to use upstream versions of mem_size_mb(), cpu_count(), and running_processes()
Filename:
MIME Type:
Creator:
George Beshers
Created:
2007-06-06 14:41:44 UTC
Size:
2.74 KB
patch
obsolete
>diff -purN udev-095.a/udevd.c udev-095.b/udevd.c >--- udev-095.a/udevd.c 2007-06-06 10:14:50.000000000 -0400 >+++ udev-095.b/udevd.c 2007-06-06 10:25:44.000000000 -0400 >@@ -312,51 +312,43 @@ static void msg_queue_insert(struct ueve > > static int mem_size_mb(void) > { >- int f; >- char buf[8192]; >- long int len; >- const char *pos; >- long int memsize; >- >- f = open("/proc/meminfo", O_RDONLY); >- if (f == -1) >- return -1; >- >- len = read(f, buf, sizeof(buf)-1); >- close(f); >+ FILE* f; >+ char buf[4096]; >+ long int memsize = -1; > >- if (len <= 0) >+ f = fopen("/proc/meminfo", "r"); >+ if (f == NULL) > return -1; >- buf[len] = '\0'; > >- pos = strstr(buf, "MemTotal: "); >- if (pos == NULL) >- return -1; >+ while (fgets(buf, sizeof(buf), f) != NULL) { >+ long int value; > >- if (sscanf(pos, "MemTotal: %ld kB", &memsize) != 1) >- return -1; >+ if (sscanf(buf, "MemTotal: %ld kB", &value) == 1) { >+ memsize = value / 1024; >+ break; >+ } >+ } > >- return memsize / 1024; >+ fclose(f); >+ return memsize; > } > > static int cpu_count(void) > { > FILE* f; >- char buf[1024]; >- int len; >- const char *pos; >+ char buf[4096]; > int count = 0; > > f = fopen("/proc/stat", "r"); > if (f == NULL) > return -1; > >- while (fgets(buf, 1024, f) != NULL) { >+ while (fgets(buf, sizeof(buf), f) != NULL) { > if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3])) > count++; > } >- fclose(f); > >+ fclose(f); > if (count == 0) > return -1; > return count; >@@ -365,45 +357,24 @@ static int cpu_count(void) > static int running_processes(void) > { > FILE* f; >- char buf[1024]; >- int len; >+ char buf[4096]; > int running = -1; >- const char *pos; >- int retries = 3; > >- /* >- * The retries is probably overkill but the text display is >- * changing rapidly.on large systems (>= 512p) and so, while >- * I have not actually recorded an instance where the retry >- * was used I would rather not have it fail. >- * >- * An alternative approach would be to note when we are on >- * a fairly large system (8cpus and 16Gbytes say) at which >- * point throttling is probably not really necessary. >- */ >- do { >- f = fopen("/proc/stat", "r"); >- if (f == NULL) >- return -1; >- >- while (fgets(buf, 1024, f) != NULL) { >- pos = strstr(buf, "procs_running "); >- if (pos != NULL) { >- int res; >- res = sscanf(pos, "procs_running %u", >- &running); >- if (res == 1) { >- fclose(f); >- return running; >- } >- break; >- } >- } >+ f = fopen("/proc/stat", "r"); >+ if (f == NULL) >+ return -1; > >- fclose(f); >- } while (retries-- > 0); >+ while (fgets(buf, sizeof(buf), f) != NULL) { >+ int value; > >- return -1; >+ if (sscanf(buf, "procs_running %u", &value) == 1) { >+ running = value; >+ break; >+ } >+ } >+ >+ fclose(f); >+ return running; > } > > /* return the number of process es in our session, count only until limit */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 226997
:
149299
|
153906
|
154301
| 156355