Closed Bug 794051 Opened 7 years ago Closed 7 years ago

Invalid use of fscanf in GonkHal.cpp

Categories

(Firefox OS Graveyard :: General, defect)

All
Gonk (Firefox OS)
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tzimmermann, Assigned: tzimmermann)

Details

Attachments

(1 file, 2 obsolete files)

A call to fscanf in uses a wrong parameter to read a string.

> /home/tdz/Projects/mozilla/src/mozilla-inbound/upstream/hal/gonk/GonkHal.cpp: In function 'void mozilla::hal_impl::GetCurrentBatteryInformation(mozilla::hal::BatteryInformation*)':
> /home/tdz/Projects/mozilla/src/mozilla-inbound/upstream/hal/gonk/GonkHal.cpp:353: warning: format '%s' expects type 'char*', but argument 3 has type 'char (*)[16]'

The call should be replaced by fgets, which checks array bounds.
Summary: Invalid use of fscanf usage in GankHal.cpp → Invalid use of fscanf usage in GonkHal.cpp
Summary: Invalid use of fscanf usage in GonkHal.cpp → Invalid use of fscanf in GonkHal.cpp
Attached patch Read battery status via fgets (obsolete) — Splinter Review
Attachment #664842 - Flags: review?(dhylands)
Attached patch Check for fgets errors (obsolete) — Splinter Review
Attachment #664843 - Flags: review?(dhylands)
(In reply to Thomas Zimmermann from comment #1)
> Created attachment 664842 [details] [diff] [review]
> Read battery status via fgets

I verified that the phone still switches correctly among charging states.
Looks good. r=me if you squash the 2 patches into one.
Squashed and updated. Dave, please commit the patch if you're OK with it.
Attachment #664842 - Attachment is obsolete: true
Attachment #664843 - Attachment is obsolete: true
Attachment #664842 - Flags: review?(dhylands)
Attachment #664843 - Flags: review?(dhylands)
Attachment #664969 - Flags: review?(dhylands)
Attachment #664969 - Flags: review?(dhylands) → review+
https://hg.mozilla.org/mozilla-central/rev/20169e3f33b3
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.